-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
Description
Error
Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.
To configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
before using any of Enzyme's top level APIs, where `Adapter` is the adapter
corresponding to the library currently being tested. For example:
import Adapter from 'enzyme-adapter-react-15';
To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html
Libraries Versions
"enzyme-to-json": "^3.3.5"
"enzyme-adapter-react-15": "^1.3.0",
"enzyme": "^3.8.0",
"react": "^15.4.0",
"react-dom": "^15.4.0",
"jest": "^19.0.2",
How to reproduce?
This is a quite clean repro-case with only the essential parts.
https://gist.github.com/Ranguro/a14b6b8e6868ff508b80f29df8a99971
I believe the problem is linked to this specific line in my package.json
"snapshotSerializers": [
"<rootDir>/node_modules/enzyme-to-json/serializer"
]
When I add this line - the Enzyme Internal Error is being thrown. If I remove it and instead- run the following, it doesn't throw the error:
https://gist.github.com/Ranguro/f318b60054f415fd2a418900c2562742
See how I added toJson from enzyme-to-json there and the test passes.
This is my setupTests.js for the enzyme adapter.
/*eslint-disable*/
var enzyme = require('enzyme');
var Adapter = require('enzyme-adapter-react-15');
enzyme.configure({ adapter: new Adapter() });
This is how I setup my setupTests.js
"setupTestFrameworkScriptFile": "<rootDir>/config/jest/setupTests.js",
Other Comments
I tried throw new Error('fail') to check if the configurations was being run when running tests and it showed the output well.
● Test suite failed to run
fail
at Object.<anonymous> (config\jest\setupTests.js:6:7)