diff --git a/README.md b/README.md index 98dfefe4cf5d..a0a38100eee0 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Now run your Jest test command. (Usually, `npm test`.) Then you can see all of y ## Options -### configPath +### `configPath` By default Storyshots assume the default config directory path for your project as below: @@ -64,7 +64,7 @@ initStoryshots({ }); ``` -### suit +### `suit` By default, we group stories inside Jest test suit called "StoryShots". You could change it like this: @@ -73,3 +73,15 @@ initStoryshots({ suit: 'MyStoryShots' }); ``` + +### `storyRegex` + +If you'd like to only run a subset of the stories for your snapshot tests: + +```js +initStoryshots({ + storyRegex: /buttons/ +}); +``` + +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).)*$/`. diff --git a/src/index.js b/src/index.js index 99665d3ae570..2f8c2eb866b5 100644 --- a/src/index.js +++ b/src/index.js @@ -51,6 +51,10 @@ export default function testStorySnapshots (options = {}) { describe(suit, () => { describe(group.kind, () => { for (const story of group.stories) { + if (options.storyRegex && !story.name.match(options.storyRegex)) { + continue + } + it(story.name, () => { const context = { kind: group.kind, story: story.name } const renderedStory = story.render(context)