TypeError: Adapter is not a constructor
krotsky opened this issue · comments
Raman Krot commented
I have such a setup file:
import * as Enzyme from 'enzyme';
import * as Adapter from '@wojtekmaj/enzyme-adapter-react-17';
Enzyme.configure({ adapter: new Adapter() });
in package I have:
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1"
"enzyme": "^3.11.0"
and my jest output is:
Test suite failed to run
TypeError: Adapter is not a constructor
2 | import * as Adapter from '@wojtekmaj/enzyme-adapter-react-17';
3 |
> 4 | Enzyme.configure({ adapter: new Adapter() });
| ^
at Object.<anonymous> (src/setupTests.js:4:29)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.466 s
Please help me to figure out this error
Wojciech Maj commented
You're not importing the adapter as described in documentation.
Raman Krot commented
You're not importing the adapter as described in documentation.
It works, thank you!
cellebriteevi commented
I think I have a somewhat similar issue:
● Test suite failed to run
TypeError: enzyme_adapter_react_17_1.default is not a constructor
6 | import {configure, shallow} from 'enzyme';
7 | import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
> 8 | configure ({ adapter: new Adapter() });
Dependencies:
- "@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
- "enzyme": "^3.11.0",
- "jest": "^27.3.1",
- "react": "^17.0.2",
- "react-dom": "^17.0.2",