Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Add regex to match the story's kind #91

Closed
olistic opened this issue Mar 28, 2017 · 2 comments
Closed

Add regex to match the story's kind #91

olistic opened this issue Mar 28, 2017 · 2 comments

Comments

@olistic
Copy link

olistic commented Mar 28, 2017

What do you guys think about having these two config options: storyKindRegex and storyNameRegex instead of the current storyRegex?

storyNameRegex would behave just as the existing storyRegex, while storyKindRegex would match against the story's kind, giving users more flexibility.

For example, it could be used to solve #84 doing something like this:

// SomeComponent.stories.js

// ...
storiesOf('SomeComponent', module)
    .add('foo', () => {
        // ...
    });
// SomeComponent.test.js

import initStoryshots from 'storyshots';

initStoryshots({
  storyKindRegex: /^SomeComponent$/,
});

Which will cause storyshots (or jest actually) to output a __snapshots__ directory colocated with the component and with just its storyshots.

If you think it is a good idea, I'm happy to submit a PR!

@olistic
Copy link
Author

olistic commented Mar 28, 2017

I guess I'm submitting the PR anyway, it's simple enough and I need it for my projects.

@alex35mil
Copy link

Why not just writing snapshots next to the stories file? W/o dummy regexp for each component.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants