Cannot find module 'enzyme/build/react-compat'
DonGiulio opened this issue · 4 comments
DonGiulio commented
I just installed chai enzyme on my app, using:
npm install chai-enzyme --save-dev
and tried to import it in my DirectionsMap mocha-enzyme-chai-chai_enzyme test:
import React from "react";
import { shallow } from "enzyme";
import chai from "chai";
import chaiEnzyme from "chai-enzyme";
import DirectionsMap from "../DirectionsMap";
describe("<DirectionsMap/>", function() {
const fron = { latitude: 20.0, longitude: 10.0 };
const to = { latitude: 24.0, longitude: 14.0 };
it("makes an Iframe", function() {
const component = shallow(<DirectionsMap from={fron} to={to} />);
console.log(component.debug());
expect(component).to.matchSnapshot();
const iframe = component.find("Styled(Iframe)");
expect(iframe).to.have.length(1);
expect(iframe).to.have.attr("url");
});
});
chai.use(chaiEnzyme());
I'm getting this error though, it looks like there's an unresolved dependency:
Error: Cannot find module 'enzyme/build/react-compat'
at Function.Module._resolveFilename (module.js:485:15)
at Function._module2.default._resolveFilename (/Users/user/Documents/user/project/project/node_modules/require-hacker/babel-transpiled-modules/require hacker.js:442:34)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/user/Documents/user/project/project/node_modules/chai-enzyme/build/ReactTestWrapper.js:9:20)
at Module._compile (module.js:569:30)
ljharb commented
What versions of chai-enzyme and enzyme are you using? Make sure npm ls
exits successfully, or else nothing can be expected to work.
DonGiulio commented
indeed npm ls reports some failures:
npm ERR! peer dep missing: enzyme@1.x || ^2.3.0, required by chai-enzyme@0.8.0
npm ERR! peer dep missing: react@^0.14.0 || ^15.0.0-0, required by chai-enzyme@0.8.0
npm ERR! peer dep missing: react-dom@^0.14.0 || ^15.0.0-0, required by chai-enzyme@0.8.0
npm ERR! peer dep missing: cheerio@0.19.x || 0.20.x || 0.22.x || 1.0.0-rc.1, required by chai-enzyme@0.8.0
ljharb commented
Sounds like you have 0.8.0, but enzyme 3 requires 1.0.0-beta something.