-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unmount is not working as described in the docs #785
Comments
@ml9951 I tried to reproduce using the same version of Enzyme, but everything worked for me. You can see my test here: https://github.com/aweary/enzyme-test-repo/blob/issue-785/test.js What version of React are you using? |
That is interesting. I tried your example and it is working for me. I also replaced your |
OK, I've managed to reproduce it in a fork of your repo: https://github.com/ml9951/enzyme-test-repo/tree/issue-785. Installing the dependencies and running |
Thanks for the repo! I was able to reproduce your issue with it. That is super weird. Those tests appear to be fully isolated (mounting two distinct components) but removing the first test cases the second to pass again 😕 The stack trace for the error seems to indicate it has something to do with your Flux dispatcher: Stack trace:
I suspect it's because of the first test being asynchronous and the second is synchronous. The test passes if you make the second test asynchronous and delay the process.nextTick(() => {
const wrapper = mount(<Foo id="foo" />);
expect(willMount.callCount).toEqual(1);
expect(didMount.callCount).toEqual(1);
expect(willUnmount.callCount).toEqual(0);
wrapper.unmount();
expect(willMount.callCount).toEqual(1);
expect(didMount.callCount).toEqual(1);
expect(willUnmount.callCount).toEqual(1);
done()
}) |
Had the same issue. In my case simply making all of the tests asynchronous did the trick to have |
I was experiencing some unintuitive behavior from
unmount
. I took the example from the docs:And got the following result:
Line 180 corresponds to:
expect(willUnmount.callCount).toEqual(1);
It seems as thoughcomponentWillUnmount
is not actually getting called. Relevant dependencies include:The text was updated successfully, but these errors were encountered: