Enzyme: Cannot find module 'react-dom' from 'react-compat.js'

Created on 9 Feb 2017  路  2Comments  路  Source: enzymejs/enzyme

Hello everyone!

While trying to execute tests in my project I get the following error:

Cannot find module 'react-dom' from 'react-compat.js'

My environment is as follows:

  1. "react": "^15.4.2",
  2. "react-addons-test-utils": "^15.4.2",
  3. "jest": "18.1.0",
  4. "react-native": "0.40.0",
  5. "enzyme": "^2.7.1",

In my test file I have imports in the following order:

import * as React from 'react';
import 'react-native';
import { shallow } from 'enzyme';

I've read common problems and tried to search through issues, but haven't found anything. Sorry if I missed something.

Most helpful comment

You also need react-dom installed, even if you're not using it.

All 2 comments

You also need react-dom installed, even if you're not using it.

@ljharb thank you for blazingly fast answer!

That solved an issue. It seems like it's worth mentioning in the React Native setup guide.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blainekasten picture blainekasten  路  3Comments

rexonms picture rexonms  路  3Comments

benadamstyles picture benadamstyles  路  3Comments

amcmillan01 picture amcmillan01  路  3Comments

AdamYahid picture AdamYahid  路  3Comments