React in version 16.3 introduces new Context API. That API comes with two new node types (12 and 13).
These node types are not supported and therefore enzyme-adapter-react-16 is throwing an error:
# for ContextConsumer
Enzyme Internal Error: unknown node with tag 12
or
# for ContextProvider
Enzyme Internal Error: unknown node with tag 13
when you use Context API inside your React components.
An example:
import React from 'react';
import { mount } from 'enzyme';
const { Provider, Consumer } = React.createContext();
const Component = () => (
<Provider value="test">
<Consumer>{value => <span>{value}</span>}</Consumer>
</Provider>
);
mount(<Component />); // this will thrown an error mentioned earlier
New node types are handled correctly.
| library | version
| ---------------- | -------
| Enzyme | ^3.3.0
| React | ^16.3.0
@kkwiatkowski this is a duplicate of https://github.com/airbnb/enzyme/issues/1509, which has already been fixed by https://github.com/airbnb/enzyme/pull/1513. Just waiting on a release by enzyme 馃槩
@baldwmic thanks for your answer. For some reason I couldn't find anything around it.
Did this fix get released yet?
I still have this problem on Enzyme v3.3.0 with enzyme-adapter-react-16 v 1.1.1
No, not yet. Please be patient.
Sorry to ping here, but any ETA on the release? This is blocking a lot of people, I'd suspect. Basically we aren't able to move to the new context without breaking existing enzyme tests.
No ETA just yet. I understand the frustration and that it's blocking many people, including Airbnb, from using many of React 16's new features.
It will be released as soon as it's ready.
@ljharb just chiming in to say thanks for taking the time to do it right. Enzyme is an amazing library!
@ljharb Is there an issue we can follow that isn't closed to check on the progress of a fix here getting published?
@msluther #1553
@ljharb Thank you! 馃槃
The following packages are now released:
I got this problem with _"enzyme": "^3.9.0"_
@Fl4v10 please file a new issue
Most helpful comment
The following packages are now released: