diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts index 135d76fa..ff4b4c12 100644 --- a/.storybook/test-runner.ts +++ b/.storybook/test-runner.ts @@ -29,8 +29,15 @@ const vrtTestConfig: TestRunnerConfig = { async postVisit(page, context) { await waitForPageReady(page) await page.waitForTimeout(200) + const root = await page.$('#storybook-root') + if (!root) { + throw new Error('Root element not found') + } - const image = await page.screenshot() + const image = await root.screenshot({ + animations: 'disabled', + mask: [page.locator('img')], + }) expect(image).toMatchImageSnapshot({ customSnapshotIdentifier: context.id, customDiffDir: `${process.cwd()}/__diff_output__`,