question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not find module 'react-addon-test-utils' from 'node_modules/enzyme/build'

See original GitHub issue

Our project is using : React: ^15.5.4 react-dom: ^15.5.4 react-test-renderer: ^15.5.4

according to airbnb/enzyme website, If you are using React >=15.5, in addition to enzyme, you will have to ensure that you also have the react-dom and react-test-renderer npm modules installed, we already installed these npm modules, only that in React 0.14 or React <15.5 need to install the react-addons-test-utils. when we use enzyme to test our react component, there is a problem: can not find module 'react-addon-test-utils' from 'node_modules/enzyme/build'. If we install the module ‘react-addon-test-utils’, then the test is OK, but our React >=15.5, Why we need to install the react-addon-test-util?

Anybody has solution to this problem? Thanks~

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
rafaelkalliscommented, May 30, 2017

@ljharb same situation here,

react: ^15.5.4,
react-dom: ^15.5.4,
react-test-renderer: ^15.5.4,
enzyme: ^2.8.2

and getting:

ERROR in ./~/enzyme/build/react-compat.js
Module not found: Error: Can't resolve 'react-addons-test-utils' in '/Users/.../node_modules/enzyme/build'
 @ ./~/enzyme/build/react-compat.js 143:20-54

I’m also able to directly require react-dom/test-utils and react-test-rendered/shallow.

In my case, I’m using karma with karma-webpack.

Adding this to my webpack config removed the warnings:

externals: {
  cheerio: 'window',
  'react/addons': 'react',
  'react/lib/ExecutionEnvironment': 'react',
  'react/lib/ReactContext': 'react',
  'react-addons-test-utils': 'react-dom', // <- added this
},
4reactions
culshawcommented, Jun 23, 2017

As per @rafaelkallis in my Karma configuration (non-webpack) I added

bundle.external('react-dom/test-utils');
bundle.external('react-test-renderer/shallow');

to my karma.conf.js

This solved the problem for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReflectionTestUtils (Spring Framework 6.0.3 API)
This method delegates to setField(Object, Class, String, Object, Class) , supplying null for the targetObject and type arguments. This method does not support ......
Read more >
Guide to ReflectionTestUtils for Unit Testing - Baeldung
Learn how to use ReflectionTestUtils in unit testing by going through several examples.
Read more >
java - Use of ReflectionTestUtils.setField() in Junit testing
In your test class, you cannot set an id of your entity because of the missing setter method. Using ReflectionTestUtils.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found