Error on tests when Enzyme is added
See original GitHub issueIs this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes;
Which terms did you search for in User Guide?
I searched about testing, about enzyme and on the troubleshooting page as well.
Environment
node -v
: v6.11.3npm -v
: 4.6.1yarn --version
(if you use Yarn): 1.1.0npm ls react-scripts
(if you haven’t ejected): react-scripts@1.0.14
Then, specify:
- Operating system: Windows
Steps to Reproduce
- npm install -g create-react-app
- create-react-app test-jest-enzyme
- cd test-jest-enzyme
- Change file src/App.test.js to be:
import React from 'react';
import App from './App';
import {shallow} from "enzyme";
it('renders without crashing', () => {
shallow(<App />);
});
- npm test
Expected Behavior
The tests would pass and no exception would be thrown.
Actual Behavior
Will give:
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
at validateAdapter (node_modules/enzyme/build/validateAdapter.js:14:11)
at Object.<anonymous>.it (src/App.test.js:6:25)
Reproducible Demo
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Jest & Enzyme test error with React Context API - Stack Overflow
I am testing a React app with Jest & Enzyme. When I run npm run test I get the error in UserContext.jsx that...
Read more >Improve your test assertions and error messages with jest ...
To improve these error messages and to introduce some new good-looking assertions, we'll add the assertion library jest-enzyme to our project.
Read more >Errors in measuring enzyme activity by reaction-rate methods
Reaction-rate and two-point enzyme assays have sources of error inherent in their methodologies. There are also major errors due to the analytical system ......
Read more >Troubleshooting Common Issues with Restriction Digestion ...
In this article, we have highlighted the most common issues while performing digestion reactions and probable causes to help you resolve your hurdles....
Read more >Enzyme Linked Immunosorbent Assay - StatPearls - NCBI - NIH
ELISA testing is used to diagnose HIV infection, pregnancy tests, and blood ... Then the secondary enzyme-conjugated antibody is added and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can confirm that putting:
In the
src/setupTests.js
file solves the issue.ok, think I fixed it, not sure if it’s the correct way but it works for ejected CRA by adding to
package.json
jest property :