From 9efb43e0d2ca4c887c84ae994cd5a8136a425090 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Sun, 1 Oct 2023 00:00:00 +0100 Subject: [PATCH] build: fix dom snapshot config using svelte format for stories requires storybook to run with the --index-json flag but this breaks the storage location of DOM snapshots the configuration files in this commit fixes this and also moves them to the same location as the image snapshots --- .storybook/test-runner.ts | 1 + .../navbar.test.js.snap | 6 +++--- test-runner-jest.config.js | 13 +++++++++++++ test-runner-snapshotresolver.js | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) rename src/lib/components/__snapshots__/Navbar.stories.ts.snap => __snapshots__/navbar.test.js.snap (90%) create mode 100644 test-runner-jest.config.js create mode 100644 test-runner-snapshotresolver.js diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts index dfed69c..98dad55 100644 --- a/.storybook/test-runner.ts +++ b/.storybook/test-runner.ts @@ -15,6 +15,7 @@ const config: TestRunnerConfig = { const innerHTML = await elementHandler.innerHTML(); expect(innerHTML).toMatchSnapshot(); } + else throw "cannot find storybook DOM root to take DOM screenshot" // Image Snapshop const image = await page.screenshot(); expect(image).toMatchImageSnapshot({ diff --git a/src/lib/components/__snapshots__/Navbar.stories.ts.snap b/__snapshots__/navbar.test.js.snap similarity index 90% rename from src/lib/components/__snapshots__/Navbar.stories.ts.snap rename to __snapshots__/navbar.test.js.snap index cb27b76..e44c3b9 100644 --- a/src/lib/components/__snapshots__/Navbar.stories.ts.snap +++ b/__snapshots__/navbar.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Navbar Default smoke-test 1`] = ` +exports[`Navbar Default test 1`] = `