codeforboston / cliff-effects

Cliff effects guidance prototype (archived)
https://codeforboston.github.io/cliff-effects/#/
MIT License
30 stars 64 forks source link

Replace _all_ `shallow()` test renderings with `mount()` #966

Open knod opened 6 years ago

knod commented 6 years ago

Other than the shallow tests not catching bunches of stuff, I think we may find some things not right with our components.

knod commented 6 years ago

Or do .not.Throw() instead. One or the other.

turnerhayes commented 5 years ago

I've read the opposite advice; use shallow() unless you need something that shallow() can't do. One reason for this is that it can help you avoid needing to set up context/etc. for nested components--for example, React Router's <Link> component requires a router in its ancestry, and will throw an error if it doesn't find it. But if you're testing a component that contains a <Link> but the bit you're testing doesn't need to render the link, you can avoid that. In general, I think the idea is to only test the specific case you're testing.

knod commented 5 years ago

I hear some of that. Can't we add context and routers to our test, though? Here's an article about shallow rendering that seemed to resonate: https://blog.kentcdodds.com/why-i-never-use-shallow-rendering-c08851a68bb7