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

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

Open
knod opened this issue Nov 4, 2018 · 3 comments
Open

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

knod opened this issue Nov 4, 2018 · 3 comments

Comments

@knod
Copy link
Collaborator

knod commented Nov 4, 2018

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

@knod knod added the testing label Nov 4, 2018
@knod knod changed the title Replace _all_ shallow test renderings with mount Replace _all_ shallow() test renderings with mount() Nov 4, 2018
knod added a commit to knod/cliff-effects-1 that referenced this issue Nov 4, 2018
@knod
Copy link
Collaborator Author

knod commented Nov 4, 2018

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

knod added a commit to knod/cliff-effects-1 that referenced this issue Nov 4, 2018
All except household, which has to be fixed where the error
is happening.
@turnerhayes
Copy link
Collaborator

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
Copy link
Collaborator Author

knod commented Nov 7, 2018

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

knod added a commit that referenced this issue Nov 7, 2018
`shallow` to `mount` in steps, removes snapshots, #966
knod added a commit that referenced this issue Nov 7, 2018
`shallow()` to `mount()` for some tests as much as possible, #966
knod added a commit that referenced this issue Nov 7, 2018
A little trouble changing ManagedNumberField `shallow` to `mount` #966
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

2 participants