-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Need Help - Unable to run some custom tests with initStoryshots. #3526
Comments
Cc @igor-dv |
From the first glance, everything looks ok. Can you try to reproduce this with the latest storybook and addon-storyshots versions? |
I updated all my storybook related packages to version 3.4.3 but I still get that error.
|
Looks like it happens from the |
Yes, of course.
|
Looks like you are limiting your test to snapshot only stories with the In the story you shread the Also, something is wrong with your code here: const component = story.render(context);
const wrapper = mount(component); // what are you doing with the wrapper after
const results = axe(html); // what is html
expect(results).toHaveNoViolations(); |
Sorry about that. This is my code now.
|
I've tried now to reproduce it with the official-storybook example but didn't get this error. I think we need some more details to reproduce it. Do you have a public repo with this problem? |
I found the root of the problem. This issue is caused by |
This is a 3rd-party addon, just try to debug it during the test. Also maybe @tuchk4 can shed more light on this. You can try even to mock it with |
I'm not sure how to return a story from the mocked decorator. Can you please provide an example? Thanks! |
something like this jest.mock('storybook-readme', () => ({
withReadme: () => (story) => story()
})) |
Thanks. Everything works as expected. I will close this now. |
I don't have a question or issue to address. I'm just posting my solution here in case it helps someone else. I am also trying to leverage StoryShots to run Axe accessibility tests on all stories and ran into a similar problem. This thread helped get me half way there, but not all the way, probably because I'm not using Enzyme to render the components. Here is what ultimately worked for me: import initStoryshots from '@storybook/addon-storyshots';
import ReactDOMServer from 'react-dom/server';
import { axe, toHaveNoViolations } from 'jest-axe';
expect.extend(toHaveNoViolations);
initStoryshots({
test: async ({ story, context }) => {
const component = story.render(context);
const html = ReactDOMServer.renderToString(component);
expect(await axe(html)).toHaveNoViolations();
},
}); |
If you are reporting a bug or requesting support, start here:
Bug or support request
I want to use enzyme and jest-axe to do some accessibility tests. I was wondering if I can accomplish this by using the
test
method frominitStoryshots
.Something like this :
After I run it I get this error
Is there any way I could extract the component and use enzyme
mount
like this ?Or should I use the renderTree function ?
Any ideas on how I could make this work ?
Please specify which version of Storybook and optionally any affected addons that you're running
The text was updated successfully, but these errors were encountered: