// .storybook/test-runner.ts import {TestRunnerConfig, waitForPageReady} from '@storybook/test-runner'; import {toMatchImageSnapshot} from 'jest-image-snapshot'; const customSnapshotsDir = `${process.cwd()}/__snapshots__`; const config: TestRunnerConfig = { setup() { expect.extend({toMatchImageSnapshot}); }, async postVisit(page, context) { // use the test-runner utility to wait for fonts to load, etc. await waitForPageReady(page); await page.mouse.move(0, 2000); // If you want to take screenshot of multiple browsers, use // page.context().browser().browserType().name() to get the browser name to prefix the file name const image = await page.screenshot({animations: 'disabled'}); expect(image).toMatchImageSnapshot({ customSnapshotsDir, customSnapshotIdentifier: context.id, failureThreshold: 4, }); }, }; export default config;