enzyme-adapter-react-16 doesn't work with React v16.5.0

Created on 10 Sep 2018  路  5Comments  路  Source: enzymejs/enzyme

Describe the bug
After upgrading to React v16.5.0, all mount fails with error information: "Invariant Violation: Unable to find node on an unmounted component."

To Reproduce
Steps to reproduce the behavior:

  1. With unit test code as below
import React from 'react';
import PropTypes from 'prop-types';
import Enzyme from 'enzyme';

const {mount, shallow} = Enzyme;
const Adapter = require('enzyme-adapter-react-16');
Enzyme.configure({adapter: new Adapter()});

describe('test name', () => {
      it('foo', () => {
        const wrapper = mount(<div>hello</div>);
        expect(wrapper.html()).toMatch(/hello/);
      });
});

  1. Run the test case with enzyme

Expected behavior
It should pass, but failed.
After lock React version in 16.4.0, the same unit test passes.

Desktop (please complete the following information):

  • OS: MacOS 10.13.6
  • Node: v6.13.0
  • React: v16.5.0
Need More Information

Most helpful comment

That is also required, as v1.5.0 contains a bugfix that prevents React v16.5 from breaking.

All 5 comments

What version of react-dom are you using? The versions of react and react-dom always must be identical. (or at least the same minor)

What enzyme-adapter-react-16 package version do you use? Upgrading it to version 1.5.0 helped me.

That is also required, as v1.5.0 contains a bugfix that prevents React v16.5 from breaking.

I was also having this error, but upgrading to [email protected] fixed it for me so maybe that is all it takes?

@tyler-johnson After upgrading to h3o-next-example/package.json, it works. Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rexonms picture rexonms  路  3Comments

ahuth picture ahuth  路  3Comments

AdamYahid picture AdamYahid  路  3Comments

andrewhl picture andrewhl  路  3Comments

ivanbtrujillo picture ivanbtrujillo  路  3Comments