enzyme: Enzyme Internal Error: unknown node with tag 0
Current behavior
Gettting an error Enzyme Internal Error: unknown node with tag 0
Expected behavior
As I’m using updated versions, this issue shouldn’t be occured.
Example
import React from 'react'
import expect from 'expect'
import { configure, mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16.3'
import { Provider } from 'mobx-react'
import { Router } from 'react-router-dom'
import stores from '../../stores'
import history from '../../utils/History'
import LoginPage from './index'
configure({ adapter: new Adapter() })
describe('LoginPage', () => {
it('Rendered LoginPage', () => {
const LoginPageContainer = mount(
<Router history={history}>
<Provider authStore={stores.authStore}>
<LoginPage />
</Provider>
</Router>
)
expect(LoginPageContainer).toMatchSnapshot()
})
})
Your environment
API
- shallow
- mount
- render
Version
library | version |
---|---|
enzyme | 3.8.0 |
react | 16.6.1 |
react-dom | 16.6.1 |
react-test-renderer | 16.6.1 |
adapter (below) |
Adapter
- enzyme-adapter-react-16
- enzyme-adapter-react-16.3
- enzyme-adapter-react-16.2
- enzyme-adapter-react-16.1
- enzyme-adapter-react-15
- enzyme-adapter-react-15.4
- enzyme-adapter-react-14
- enzyme-adapter-react-13
- enzyme-adapter-react-helper
- others ( )
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 19 (6 by maintainers)
Fixed for me after update to versions below:
This issue started occurring for me after I started using
React.forwardRef
without updatingenzyme-adapter-react-16
. I updated the adapter fromv1.1.1
tov1.7.1
, which fixed the issue.You seem to be using
adapter-react-16.3
while your reported React version >=16.4
. That’s probably what’s causing the issue, and it most likely is resolved by changing toenzyme-adapter-react-16
.I was able to resolve this by using enzyme-adapter-react-16 v1.7.1. I guess I had jumped directly to enzyme-adapter-react-16.3 without thinking of simply upgrading enzyme-adapter-react-16.
There is one test that passed before this upgrade, but I guess that would be a different issue to file.
I was getting the same error with
enzyme-adapter-react-16
. Like you said, it seems like enzyme simply doesn’t yet support React 16.6 regardless of the adapter.Currently, I’m working on other things. I will try to reproduce it in a separate repo and let you know.
Thanks!
I’m going to close for now; if the failure can be reproduced I’m more than happy to reopen.