From c1c048929950b1b93312dc558a2b73048537f05d Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 19 Apr 2017 22:33:09 +1000 Subject: [PATCH] Add a `noMatchSnapshots` option. --- packages/storyshots/README.md | 4 ++++ packages/storyshots/src/index.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/storyshots/README.md b/packages/storyshots/README.md index de1482563970..5ac030cc1373 100644 --- a/packages/storyshots/README.md +++ b/packages/storyshots/README.md @@ -97,3 +97,7 @@ initStoryshots({ ``` Here is an example of [a regex](https://regex101.com/r/vkBaAt/2) which does not pass if `"Relay"` is in the name: `/^((?!(r|R)elay).)*$/`. + +### `noMatchSnapshots` + +If you don't want to run snapshot tests, but instead just ensure that your stories render without error, pass `noMatchSnapshots: true`. This will "smoke" test your stories and make sure you haven't broken anything, which is appropriate early in the development process. diff --git a/packages/storyshots/src/index.js b/packages/storyshots/src/index.js index e91c11601fe6..66797601e665 100644 --- a/packages/storyshots/src/index.js +++ b/packages/storyshots/src/index.js @@ -72,7 +72,9 @@ export default function testStorySnapshots(options = {}) { const context = { kind: group.kind, story: story.name }; const renderedStory = story.render(context); const tree = renderer.create(renderedStory).toJSON(); - expect(tree).toMatchSnapshot(); + if (!options.noMatchSnapshots) { + expect(tree).toMatchSnapshot(); + } }); } });