Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom test function for storyshots #1034

Closed
tmeasday opened this issue May 15, 2017 · 6 comments
Closed

Allow custom test function for storyshots #1034

tmeasday opened this issue May 15, 2017 · 6 comments

Comments

@tmeasday
Copy link
Member

Currently, storyshots does two things: (a) it sets up a Jest test for each story, and (b) it defines the body of that test to be a vanilla snapshot test.

However, there are different things you may want to do in step (b), for instance:

This issue proposes allowing configuring the body of the test (although keeping the current as the default). First proposed here: #917 (comment)

There is a question of how to best implement this. The simplest thing is simply an option to initStoryshots:

initStoryshots({
  test(story) {
    // make assertions (doesn't return anything).
  }
});

@theinterned made a suggestion around lifecycle methods here -- can you provide a bit more detail about how that might be used?

In terms of implementing the use cases above, I would suggest we export "test bodies" that do the standard things from storyshots. So you could do

import initStoryshots, { shallowSnapshot } from 'storyshots';

initStoryshots({ test: shallowSnapshot });
@tmeasday
Copy link
Member Author

I implemented my suggestion in #1035, but we can do something else still.

tmeasday added a commit that referenced this issue May 15, 2017
tmeasday added a commit that referenced this issue May 15, 2017
@RohovDmytro
Copy link

RohovDmytro commented May 15, 2017

There is a question of how to best implement this.

@tmeasday maybe extract step b into an own package? And storyshots addon can be used on top of it. Other addons can be build too (like #1032 or else)

Thus storyshots can still be focused on jest testing.

@tmeasday
Copy link
Member Author

@rogovdm do you mean to extract this file into its own package?

@ndelangen
Copy link
Member

ndelangen commented May 27, 2017

Is this done ? @tmeasday

@ndelangen ndelangen removed the merged label May 27, 2017
@tmeasday
Copy link
Member Author

tmeasday commented May 29, 2017

Yes, that is what I meant by the merged label @ndelangen -- I thought that was the agreed process?

@tmeasday
Copy link
Member Author

Released with v3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants