Enzyme expects an adapter to be configured Enzyme expects an adapter to be configured reactjs reactjs

Enzyme expects an adapter to be configured


Add it to your test case file.

import React from 'react';import Adapter from 'enzyme-adapter-react-16';import { shallow, configure } from 'enzyme';configure({adapter: new Adapter()});test('message box', ()=> {     ...})


Also, if you don't want to import your setupTests.js file into every test file, you can place it in your package.json folder:

  "jest": {     "setupTestFrameworkScriptFile": "./test/setupTests.js" }

Update:

Note: setupTestFrameworkScriptFile is deprecated in favor of setupFilesAfterEnv.

https://jestjs.io/docs/en/configuration


The file 'setupTests' has to be imported to the test file:

import MessageBox from "../MessageBox";import { shallow } from 'enzyme';import React from 'react';import "../setupTests"test('message box', ()=> {     ...})