-
-
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
Enzyme Internal Error: unknown node with tag 14 #1717
Comments
Hmm, that's a new one, thanks. I'm not sure if that's an issue confined to React 16 or not - it's possible that nobody's ever tried to directly mount or shallow-render a cloned element before :-) |
At least I’ve tried and it was actually working fine before. 👌🏻 |
I also have this issue when using grid-styled |
@karolisgrinkevicius can you be more specific on "before"? do you mean in enzyme 2, or in react 15 with enzyme 3, or in an earlier version of the react 16 adapter? |
@ljharb as the icon after |
ah - right :-) that implies that grid-styled updated to use fragments; as opposed to implying that enzyme has a regression around mounting fragments. |
@ljharb could you please be more specific? I'm actually looking for the concrete solution to solve this. |
@karolisgrinkevicius sure! basically, it's clear that "latest enzyme" can't mount cloned elements. It's clear that you don't run into this problem with grid-styled v4, only with v5 - but that doesn't relate to enzyme, since v4 probably isn't using cloned elements at all. What would relate to enzyme, is if grid-styled v5 works with any version of enzyme - which I suspect it does not. |
I actually created an issiue in grid_styled as well to make sure this could be solved a bit quicker. If it’s nothing that enzyme can do with you can probably close this issue. Thank you for the clarification @ljharb ! 👍🏻 |
We should be able to mount cloned elements. |
I just realized this probably has nothing to do with cloning; can you try to mount |
@ljharb please see the code below to reproduce this issue using import * as React from 'react';
import { createProvider, Provider as ReduxProvider } from 'react-redux';
import { ThemeProvider } from 'styled-components';
import * as R from 'ramda';
import { shallow, mount } from 'enzyme';
import configureStore from 'redux-mock-store';
import { theme } from 'theme'; // locally defined theme
import rootReducer from 'store/reducers'; // local root reducer
type Node = React.ReactElement<any>;
const themeInstance = shallow(<ThemeProvider theme={theme} />).instance() as any;
const StoreProvider = createProvider('store');
const createStore = configureStore();
const getStoreProvider = (initialState = {}) => {
const mockStore = createStore(R.mergeDeepRight(rootReducer({} as any, {} as any), initialState));
return new StoreProvider({ store: mockStore });
};
const getProvidersContexts = (storeProvider: any) => ({ store: storeProvider.getChildContext().store });
export const mountWithProviders = (initialState = {}) => {
const storeProvider = getStoreProvider(initialState);
return (node: Node) => {
return mount(React.cloneElement(node, getProvidersContexts(storeProvider)), {
context: { ...getProvidersContexts(storeProvider), ...themeInstance.getChildContext() },
childContextTypes: {
...ReduxProvider.childContextTypes,
...ThemeProvider.childContextTypes,
},
});
};
}; Then you can basically do this: const wrapper = mountWithProviders()(<MyComponent />); |
( Thanks, that clarifies things - that means it's definitely not cloning, it's potentially something grid-styled is doing. |
Could you please clarify what this means?
|
Yes; Typescript has broken behavior for many versions where |
I also took a try without cloning a node itself and passing it directly to mount but result is the same. |
Getting
Enzyme Internal Error: unknown node with tag 14
wheremount
is used on cloned element node. For instance:Update
After
grid-styled
reverted to4.1.1
seems to be working fine.Versions
5.0.2
☢️3.0.1
16.4.1
23.4.1
3.3.0
1.1.1
2.0.0
3.3.4
The text was updated successfully, but these errors were encountered: