-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: e2e * chore: adding next app * chore: removing next app * chore: yarn test integrated in the workflow * chore: test folder * chore: comments
- Loading branch information
Showing
9 changed files
with
1,702 additions
and
1,238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
dist/ | ||
node_modules/ | ||
storybook-static/ | ||
test/e2e/*app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ coverage/ | |
.idea | ||
yarn-error.log | ||
.size-snapshot.json | ||
test/e2e/*app | ||
__diff_output__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Suspense, useEffect } from 'react' | ||
import { Canvas } from '@react-three/fiber' | ||
import { Box, Environment, CameraControls } from '@react-three/drei' // eslint-disable-line import/no-unresolved | ||
|
||
function App() { | ||
return ( | ||
<Canvas camera={{ position: [1, 1, 1] }} style={{ width: 300, height: 150, background: 'white' }}> | ||
<Suspense fallback={null}> | ||
<Scene /> | ||
</Suspense> | ||
</Canvas> | ||
) | ||
} | ||
|
||
function Scene() { | ||
useEffect(() => { | ||
document.dispatchEvent(new Event('puppeteer:r3f')) | ||
}, []) | ||
|
||
return ( | ||
<> | ||
<Box> | ||
<meshStandardMaterial /> | ||
</Box> | ||
|
||
<Environment preset="city" /> | ||
|
||
<CameraControls /> | ||
</> | ||
) | ||
} | ||
|
||
export default App |
Binary file added
BIN
+1.68 KB
...mage_snapshots__/snapshot-test-js-snapshot-should-match-previous-one-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
PORT=5188 | ||
|
||
(cd ../../dist; npm pack) | ||
|
||
kill_app() { | ||
kill $(lsof -ti:$PORT) | ||
} | ||
|
||
kill_app || echo "ok, no previous running process on port $PORT" | ||
|
||
# | ||
# ██╗ ██╗██╗████████╗███████╗ | ||
# ██║ ██║██║╚══██╔══╝██╔════╝ | ||
# ██║ ██║██║ ██║ █████╗ | ||
# ╚██╗ ██╔╝██║ ██║ ██╔══╝ | ||
# ╚████╔╝ ██║ ██║ ███████╗ | ||
# ╚═══╝ ╚═╝ ╚═╝ ╚══════╝ | ||
# | ||
|
||
rm -rf viteapp | ||
|
||
# create app | ||
npm create vite@latest viteapp -- --template react | ||
|
||
# drei | ||
(cd viteapp; npm i; npm i ../../../dist/react-three-drei-0.0.0-semantic-release.tgz) | ||
|
||
# App.jsx | ||
cp App.jsx viteapp/src/App.jsx | ||
|
||
# build+start+jest | ||
(cd viteapp; npm run build; npm run preview -- --port $PORT &) | ||
npx jest snapshot.test.js || kill_app | ||
kill_app | ||
|
||
rm -rf viteapp | ||
|
||
# | ||
# ██████╗██████╗ █████╗ | ||
# ██╔════╝██╔══██╗██╔══██╗ | ||
# ██║ ██████╔╝███████║ | ||
# ██║ ██╔══██╗██╔══██║ | ||
# ╚██████╗██║ ██║██║ ██║ | ||
# ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ | ||
# | ||
|
||
rm -rf craapp | ||
|
||
# create app | ||
npx create-react-app craapp | ||
|
||
# drei | ||
(cd craapp; npm i ../../../dist/react-three-drei-0.0.0-semantic-release.tgz) | ||
|
||
# App.jsx | ||
cp App.jsx craapp/src/App.js | ||
|
||
# build+start+jest | ||
(cd craapp; npm run build; npx serve -s -p $PORT build &) | ||
npx jest snapshot.test.js || kill_app | ||
kill_app | ||
|
||
rm -rf craapp | ||
|
||
# | ||
# Teardown | ||
# | ||
|
||
echo "✅ e2e ok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const puppeteer = require('puppeteer') | ||
|
||
const { toMatchImageSnapshot } = require('jest-image-snapshot') | ||
expect.extend({ toMatchImageSnapshot }) | ||
|
||
async function waitForEvent(page, eventName) { | ||
await page.evaluate( | ||
(eventName) => new Promise((resolve) => document.addEventListener(eventName, resolve, { once: true })), | ||
eventName | ||
) | ||
} | ||
|
||
describe('snapshot', () => { | ||
let browser | ||
let page | ||
beforeAll(async () => { | ||
browser = await puppeteer.launch({ headless: 'new' }) | ||
page = await browser.newPage() | ||
}) | ||
|
||
it('should match previous one', async () => { | ||
// ⏳ "r3f" event | ||
await page.goto('http://localhost:5188') | ||
await waitForEvent(page, 'puppeteer:r3f') | ||
|
||
// 📸 <canvas> | ||
const $canvas = await page.$('canvas[data-engine]') | ||
const image = await $canvas.screenshot() | ||
|
||
// compare | ||
expect(image).toMatchImageSnapshot({}) | ||
}, 30000) | ||
|
||
afterAll(async () => { | ||
await browser.close() | ||
}) | ||
}) |
Oops, something went wrong.
e4897c9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
drei – ./
drei.vercel.app
drei-pmndrs.vercel.app
drei.react-spring.io
drei-git-master-pmndrs.vercel.app
drei.pmnd.rs