-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
add guide for snapshot testing permutations #181
Comments
Hello, @jthegedus. Thank you for raising this concern. It's been a struggle for me to get an effective setup of Jest to assert responsive behaviors without hard-coding any of The intent is to include this mock in any test suite that needs to assert a responsive behavior. It uses I'm not currently using this setup during the Could you please give me an example of your test suite? I would like to understand better what are you trying to test, so I can come up with guidelines. Thanks. |
I'm not even sure my idea is useful. But essentially I wanted to get a Jest snapshot of the tree in each permutation. Simply: import React from 'react';
import {render} from 'react-testing-library';
import RootPage from '../../src/pages';
describe('Root Page', () => {
it('Snapshot test for small screen', () => {
// somehow set the screen size
const {asFragment} = render(<RootPage/>);
expect(asFragment()).toMatchSnapshot();
});
it('Snapshot test for large screens', () => {
// somehow set the screen size
const {asFragment} = render(<RootPage/>);
expect(asFragment()).toMatchSnapshot();
});
}); The mock I initially provided outputs all components in the tree regardless of the screen size. Which is fine since it tracks all of the components and their changes, so again, I am not sure if splitting the snapshot out into multiple files is useful. |
I think the trickiest part is to actually react on window resize during the unit test. The setup code above I've mentioned helps to mock a
I will try to look into this, but can't promise this to be tackled any time soon. If you have time, please play around with these test suites using the mentioned jest setup and let me know the results in this thread. Much thanks! |
I will definitely share any advances in this space, thanks for the awesome layout tool! |
What:
I would like an example/guide to show snapshot testing with Jest, including conditionally rendered components as it's unclear how one should approach snapshot testing with these types of libs.
Why:
This library simplifies managing breakpoints so folks like myself don't need to learn all the intricate details. Setting up
styled-components
andjest
testing has been a struggle. Finally getting things sorted with this setup mock:worked nicely except now I can't get a snapshot of each permutation of the component. A guide on this topic would go a long way.
How:
Additional docs/examples
The text was updated successfully, but these errors were encountered: