Job listings with React, Sass modules & snapshot testing with Jest
Design comparison
Solution retrospective
- Is it a good approach to pack a number of variables into an object and pass it as a prop to some component in order to reduce the number of props to pass?
<Component data={data} />
// or
<Component prop1={val1} prop2={val2} ... />
- Should every component have a snapshot test? I used
react-test-renderer
and noticed that it renders all nested components too. So if I test, for example, a subscribe form and a whole page with it, the form gets rendered in both of these tests.
Community feedback
- @rfilenkoPosted about 4 years ago
Hey, a pretty solid work😉 As for your questions, preferable to use one object and pass it as one prop, then you can destructure needed values inside child component. No experience with test-rendered, only used e2e cypress to simulate user experience.
Keep coding and have fun, Roman
3 - @mattstuddertPosted about 4 years ago
Nice work, Alex! I agree with Roman regarding passing the object and then destructuring as you need in the child component. With snapshots, I tend to focus them at the page level because of the full render. That way you have fewer tests, but they're detecting changes all the way down the tree.
Keep up the great work!
2
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord