-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from kitsuyui/add-vrt-test
Introduce VRT test
- Loading branch information
Showing
10 changed files
with
134 additions
and
8 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,29 @@ | ||
name: test-vrt | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: macos-latest | ||
continue-on-error: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: latest | ||
cache: yarn | ||
cache-dependency-path: yarn.lock | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn build | ||
|
||
- name: Visual Regression Test | ||
run: yarn test:vrt | ||
|
||
- uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: playwright-report | ||
path: examples/storybook/playwright-report/ | ||
retention-days: 1 |
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 @@ | ||
playwright-report |
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,58 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
// https://playwright.dev/docs/test-configuration | ||
export default defineConfig({ | ||
// Look for test files in the "tests" directory, relative to this configuration file. | ||
testDir: 'tests', | ||
|
||
// Run all tests in parallel. | ||
fullyParallel: true, | ||
|
||
// Fail the build on CI if you accidentally left test.only in the source code. | ||
forbidOnly: !!process.env.CI, | ||
|
||
// Retry on CI only. | ||
retries: process.env.CI ? 2 : 0, | ||
|
||
// Opt out of parallel tests on CI. | ||
workers: process.env.CI ? 1 : undefined, | ||
|
||
// Reporter to use | ||
reporter: 'html', | ||
|
||
expect: { | ||
// Maximum time expect() should wait for the condition to be met. | ||
timeout: 5000, | ||
|
||
// toHaveScreenshot: { | ||
// // An acceptable amount of pixels that could be different, unset by default. | ||
// maxDiffPixels: 1, | ||
// }, | ||
|
||
// toMatchSnapshot: { | ||
// // An acceptable ratio of pixels that are different to the total amount of pixels, between 0 and 1. | ||
// maxDiffPixelRatio: 0.0125, | ||
// }, | ||
}, | ||
|
||
use: { | ||
// Base URL to use in actions like `await page.goto('/')`. | ||
baseURL: 'http://127.0.0.1:6006', | ||
|
||
// Collect trace when retrying the failed test. | ||
trace: 'on-first-retry', | ||
}, | ||
// Configure projects for major browsers. | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
// Run your local dev server before starting the tests. | ||
webServer: { | ||
command: 'yarn start', | ||
url: 'http://127.0.0.1:6006', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
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,10 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('clock page', async ({ page }) => { | ||
await page.goto('http://localhost:6006/?path=/story/clock--default') | ||
await page.waitForSelector('iframe[data-is-loaded="true"]') | ||
const screenshot = await page | ||
.locator('#storybook-preview-iframe') | ||
.screenshot() | ||
expect(screenshot).toMatchSnapshot('clock-image.png') | ||
}) |
Binary file added
BIN
+7.6 KB
examples/storybook/tests/example.spec.ts-snapshots/clock-image-chromium-darwin.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
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
}, | ||
"test": { | ||
"dependsOn": ["^test"] | ||
} | ||
}, | ||
"test:vrt": {} | ||
} | ||
} |
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