From d7fe4469ccb31d3764416b5079f36e4a1ce02beb Mon Sep 17 00:00:00 2001 From: Kotaro Sugawara Date: Tue, 11 Sep 2018 19:01:38 +0900 Subject: [PATCH] =?UTF-8?q?Fixed=20storyshots=20config=20=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E3=81=AE?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=BC=E3=83=AA=E3=81=94=E3=81=A8=E3=81=AB?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=20=5F=5Fsnapshots?= =?UTF-8?q?=5F=5F=20=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20https://github.com/storybooks/storybook/issues/3483?= =?UTF-8?q?=20https://github.com/storybooks/storybook/issues/887?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ignore.d.ts | 2 ++ package.json | 1 + .../App/__snapshots__/index.stories.storyshot} | 0 src/storyshots.test.ts | 13 ++++++++++--- yarn.lock | 6 ++++++ 5 files changed, 19 insertions(+), 3 deletions(-) rename src/{__snapshots__/storyshots.test.ts.snap => components/App/__snapshots__/index.stories.storyshot} (100%) diff --git a/ignore.d.ts b/ignore.d.ts index e6c4689..1953f05 100644 --- a/ignore.d.ts +++ b/ignore.d.ts @@ -1,2 +1,4 @@ declare module 'storybook-addon-smart-knobs'; declare module 'react-stubber'; +declare module 'jest-styled-components/src/styleSheetSerializer'; +declare module 'jest-specific-snapshot'; diff --git a/package.json b/package.json index 2b6251a..9b6d99c 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.1.1", "husky": "^1.0.0-rc.13", + "jest-specific-snapshot": "^1.0.0", "jest-styled-components": "^6.2.0", "lint-staged": "^7.2.0", "prettier": "^1.13.7", diff --git a/src/__snapshots__/storyshots.test.ts.snap b/src/components/App/__snapshots__/index.stories.storyshot similarity index 100% rename from src/__snapshots__/storyshots.test.ts.snap rename to src/components/App/__snapshots__/index.stories.storyshot diff --git a/src/storyshots.test.ts b/src/storyshots.test.ts index b64dbdf..b032b50 100644 --- a/src/storyshots.test.ts +++ b/src/storyshots.test.ts @@ -1,7 +1,14 @@ -import initStoryshots from '@storybook/addon-storyshots'; +import initStoryshots, { + multiSnapshotWithOptions, +} from '@storybook/addon-storyshots'; import { setStubbingMode } from 'react-stubber'; -import 'jest-styled-components'; +import styleSheetSerializer from 'jest-styled-components/src/styleSheetSerializer'; +import { addSerializer } from 'jest-specific-snapshot'; setStubbingMode(true); -initStoryshots({}); +addSerializer(styleSheetSerializer); + +initStoryshots({ + test: multiSnapshotWithOptions({}), +}); diff --git a/yarn.lock b/yarn.lock index ad7aa87..cdd3f52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6515,6 +6515,12 @@ jest-specific-snapshot@^0.5.0: dependencies: jest-snapshot ">=20.0.3" +jest-specific-snapshot@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/jest-specific-snapshot/-/jest-specific-snapshot-1.0.0.tgz#157c79e2534a6fea820fd475f5d17740c8f90833" + dependencies: + jest-snapshot ">=20.0.3" + jest-styled-components@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/jest-styled-components/-/jest-styled-components-6.2.0.tgz#a8cbb39ff21a968e11a154c60b6e8c7b284595ff"