'I'm trying to use enzyme in my React project for testing, but it throws this error: Cannot find module 'enzyme' from 'setupTests.js'
I already ran the command npm install --save-dev @ wojtekmaj / enzyme-adapter-react-17 in my project.
Put this in my setupTests.js file:
import Enzyme from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
Enzyme.configure({ adapter: new Adapter() });
And when I start running the tests I get the error.
This is my test file:
PrimeraApp.test.js
import React from "react";
import PrimeraApp from "../PrimeraApp";
import { shallow } from "enzyme";
describe("PrimeraApp.js", () => {
test("Debe mostrar <PrimeraApp /> correctamente", () => {
const saludo = "Hola mundo";
const wrapper = shallow(<PrimeraApp saludo={saludo} />);
expect(wrapper).toMatchSnapshot();
});
});
If you can help me, Thank you.
Solution 1:[1]
You have to install enzyme package as well. npm i --save enzyme
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | trusca dan |
