Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'enzyme/build/react-compat' #213

Closed
DonGiulio opened this issue Dec 3, 2017 · 4 comments
Closed

Cannot find module 'enzyme/build/react-compat' #213

DonGiulio opened this issue Dec 3, 2017 · 4 comments

Comments

@DonGiulio
Copy link

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
Copy link
Member

ljharb commented Dec 3, 2017

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
Copy link
Author

indeed npm ls reports some failures:

npm ERR! peer dep missing: [email protected] || ^2.3.0, required by [email protected]
npm ERR! peer dep missing: react@^0.14.0 || ^15.0.0-0, required by [email protected]
npm ERR! peer dep missing: react-dom@^0.14.0 || ^15.0.0-0, required by [email protected]
npm ERR! peer dep missing: [email protected] || 0.20.x || 0.22.x || 1.0.0-rc.1, required by [email protected]

@ljharb
Copy link
Member

ljharb commented Dec 3, 2017

Sounds like you have 0.8.0, but enzyme 3 requires 1.0.0-beta something.

@ayrton
Copy link
Contributor

ayrton commented Dec 3, 2017

Correct, see #199 for more information on support with enzyme 3

@ayrton ayrton closed this as completed Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants