-
Notifications
You must be signed in to change notification settings - Fork 38
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 #475 from pixiv/mimo/add-test-runner-setting-for-i…
…mage-snapshots Configured test-runner for image snapshot testing
- Loading branch information
Showing
5 changed files
with
136 additions
and
463 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
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 |
---|---|---|
@@ -1,7 +1,24 @@ | ||
import type { TestRunnerConfig } from '@storybook/test-runner' | ||
import { waitForPageReady, type TestRunnerConfig } from '@storybook/test-runner' | ||
import { toMatchImageSnapshot } from 'jest-image-snapshot' | ||
|
||
const config: TestRunnerConfig = { | ||
// | ||
setup() { | ||
expect.extend({ toMatchImageSnapshot }) | ||
}, | ||
async postVisit(page, context) { | ||
await waitForPageReady(page) | ||
const image = await page.screenshot() | ||
expect(image).toMatchImageSnapshot({ | ||
customSnapshotIdentifier: context.id, | ||
customDiffDir: `${process.cwd()}/__diff_output__`, | ||
customSnapshotsDir: `${process.cwd()}/__image_snapshots__`, | ||
failureThresholdType: 'percent', | ||
failureThreshold: 0.001, | ||
}) | ||
}, | ||
tags: { | ||
skip: ['skip-test'], | ||
}, | ||
} | ||
|
||
export default config |
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
Oops, something went wrong.