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

Component is not updated after simulating error #1809

Closed
aliaksandr-yermalayeu opened this issue Sep 7, 2018 · 7 comments · Fixed by #1812
Closed

Component is not updated after simulating error #1809

aliaksandr-yermalayeu opened this issue Sep 7, 2018 · 7 comments · Fixed by #1812

Comments

@aliaksandr-yermalayeu
Copy link

Describe the bug
Component is not rendered correctly after error simulation

Possibly related issues: #1757, #1283

To Reproduce
I created minimal repo with contained issue. Clone it, run npm i, then run tests with npm test command. One snapshot will fail.

2018-09-07 19_33_09-dimscreen screen

Expected behavior
Error message should be rendered instead of normal content. It works fine with shallow and fails with mount

Desktop:

  • OS: win7
  • Version 3.6.0
@ljharb
Copy link
Member

ljharb commented Sep 7, 2018

enzyme has no snapshot support; the closest would be .debug().

Can you update your test cases to assert that either Component or Error have a length of 1, as you'd expect?

@asapach
Copy link

asapach commented Sep 7, 2018

@ljharb, could you please explain why it works with shallow() and doesn't work with mount()?

@aliaksandr-yermalayeu
Copy link
Author

enzyme has no snapshot support; the closest would be .debug().

There was no difference after I replaced snapshots with .debug(), except formatting.

Can you update your test cases to assert that either Component or Error have a length of 1, as you'd expect?

No problem. I updated repo, removed all unnecessary tests, added one similar test with pure error for comparison.

2018-09-08 01_11_21-dimscreen screen

@ljharb
Copy link
Member

ljharb commented Sep 8, 2018

@asapach mount uses react itself to render; shallow uses react-test-renderer. It's possible/likely that there's bugs in react-test-renderer, or in enzyme's use of it.

@jgzuke
Copy link
Collaborator

jgzuke commented Sep 8, 2018

It looks like this is being caused by simulateError not calling update on the wrapper. The reason this is working for shallow is that when you .find on a shallow node update gets called internally`.

@aliaksandr-yermalayeu for now you can add a container.update() call to your test after calling simulateError

@aliaksandr-yermalayeu
Copy link
Author

@jgzuke I suspected something like that. Thank you for the clarification.

@ljharb
Copy link
Member

ljharb commented Sep 10, 2018

Reopening until #1812 lands.

@ljharb ljharb reopened this Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants