-
-
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
wrapper.instance() throws error after wrapper.unmount() #956
Comments
|
Yeah, that's a nice workaround, thanks! I think it's still a bug, though. I don't know the internals, but clearly the instance still exists after This could be either fixed so that |
Fair points. I think it's worth ensuring Does this only happen on |
With Here is still a minimal snippet to reproduce the original problem with
|
I could try to take a crack at this. |
I took a shot at this in #969 The issue was that unmount causes the ReactWrapperComponent render to return null which renders an empty component. Apparently empty components don't have the |
When calling
wrapper.instance()
afterwrapper.unmount()
it throwsTypeError: component.getPublicInstance is not a function
The use-case for accessing the React component instance after the unmount is to check that any possible teardown in
componentWillUnmount()
has been successful. In my particular use-case I want to check that an RxJS Subscription has been unsubscribed.Code to reproduce:
Test output:
There is a workaround by using
wrapper.node
instead ofwrapper.instance()
in the last expect:expect(wrapper.node).toHaveProperty('subscription.closed', true);
. But this feels dirty because.node
is an undocumented feature.Used versions:
enzyme: 2.8.2
jest: 20.0.3
react: 15.5.4
react-scripts: 1.0.5
rxjs: 5.4.0
enzyme-to-json: 1.5.1 (I don't think this affects this particular test, but I had it installed anyway)
The text was updated successfully, but these errors were encountered: