I have a problem calling enzym's
mount
function. It says:
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';
My setupTests.js
file looks like this:
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
and in package.json:
"jest": {
"testEnvironment": "jest-environment-jsdom-global",
"setupFiles": [
"<rootDir>/jestConfigs/setupTests.js"
],
"moduleNameMapper": {
"^.+\\.(css|scss)$": "<rootDir>/jestConfigs/CSSStub.js",
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/jestConfigs/fileStub.js",
"/common-mms/(.+)": "<rootDir>/App/common-mms/$1"
}
},
But the problem is - I am using react-16 and enzyme-adapter-react-15 is irrelevant for me. Even if I add enzyme-adapter-react-15 just in case - the error still remains.
UPDATE:
If I copy content of setupTests.js into beginning of each test file - all works fine!
And if I put console.log(1)
into setupTests - it actually prints! Meaning that the file is actually improted on jest initialization.