-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add visual regression testing
add image and dom snapshot comparison for storybook components image snapshot comparison can been flaky and produce many false-positives. a higher threshold has been used to mitigate this although it may not identify all regressions. DOM snapshots supplement images to increase the likelihood of capturing regressions.
- Loading branch information
1 parent
d6fd198
commit d663869
Showing
8 changed files
with
2,073 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Install Playwright Browsers | ||
run: yarn playwright install --with-deps | ||
- name: Run Storybook tests | ||
run: yarn test-storybook:ci | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
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,29 @@ | ||
import type { TestRunnerConfig } from "@storybook/test-runner"; | ||
import { toMatchImageSnapshot } from 'jest-image-snapshot'; | ||
|
||
const customSnapshotsDir = `${process.cwd()}/__snapshots__`; | ||
|
||
|
||
const config: TestRunnerConfig = { | ||
setup() { | ||
expect.extend({ toMatchImageSnapshot }); | ||
}, | ||
async postRender(page, context) { | ||
// DOM Snapshot | ||
const elementHandler = await page.$('#storybook-root'); | ||
if (elementHandler) { | ||
const innerHTML = await elementHandler.innerHTML(); | ||
expect(innerHTML).toMatchSnapshot(); | ||
} | ||
// Image Snapshop | ||
const image = await page.screenshot(); | ||
expect(image).toMatchImageSnapshot({ | ||
customSnapshotsDir, | ||
customSnapshotIdentifier: context.id, | ||
failureThresholdType: 'percent', | ||
failureThreshold: 0.002, | ||
}); | ||
}, | ||
}; | ||
|
||
export default config; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,76 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Navbar Default smoke-test 1`] = ` | ||
<div class="navbar bg-neutral"> | ||
<div class="flex-1"> | ||
<h4> | ||
<span class="primary"> | ||
git | ||
</span> | ||
<span class> | ||
together | ||
</span> | ||
<span class> | ||
.xyz | ||
</span> | ||
</h4> | ||
</div> | ||
<div class="flex-none gap-4"> | ||
<div class="btn btn-primary normal-case"> | ||
Sign up | ||
</div> | ||
<button class="btn btn-outline normal-case"> | ||
Login | ||
</button> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Navbar NIP07Exists smoke-test 1`] = ` | ||
<div class="navbar bg-neutral"> | ||
<div class="flex-1"> | ||
<h4> | ||
<span class="primary"> | ||
git | ||
</span> | ||
<span class> | ||
together | ||
</span> | ||
<span class> | ||
.xyz | ||
</span> | ||
</h4> | ||
</div> | ||
<div class="flex-none gap-4"> | ||
<button class="btn btn-outline normal-case"> | ||
Login | ||
</button> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`Navbar NoNIP07 smoke-test 1`] = ` | ||
<div class="navbar bg-neutral"> | ||
<div class="flex-1"> | ||
<h4> | ||
<span class="primary"> | ||
git | ||
</span> | ||
<span class> | ||
together | ||
</span> | ||
<span class> | ||
.xyz | ||
</span> | ||
</h4> | ||
</div> | ||
<div class="flex-none gap-4"> | ||
<div class="btn btn-primary normal-case"> | ||
Sign up | ||
</div> | ||
<button class="btn btn-outline normal-case"> | ||
Login | ||
</button> | ||
</div> | ||
</div> | ||
`; |
Oops, something went wrong.