I get the following error in my test suite when I upgrade from React 12.2 to React 13.3:
Error: Invariant violation: unmountComponentAtNode (...): Target container is not a DOM element.
I use this blog post to test my code with Jasmine. An error occurs in this code:
describe("A component", function() { var instance; var container = document.createElement("div"); afterEach(function() { if (instance && instance.isMounted()) {
I know getDOMNode() deprecated, but that is not what causes the error.
When I check instance.getDOMNode() , it returns the given instance, but when it is wrong, instance.getDOMNode().parent is undefined. Calling React.unmountComponentAtNode on this undefined variable throws an error.
The answers to this suggest that there is some kind of race condition, but I'm not sure how this applies to my test suite. Thanks for any help!
source share