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.

enzyme adapter giving ERROR in ./~/react-test-renderer/package.json

See original GitHub issue

I am getting the following error trace

@ ./~/enzyme-adapter-react-16/build/ReactSixteenAdapter.js 27:15-58
25 04 2019 18:29:18.689:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
25 04 2019 18:29:18.691:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
25 04 2019 18:29:18.695:INFO [launcher]: Starting browser ChromeHeadless
25 04 2019 18:29:19.197:INFO [HeadlessChrome 75.0.3738 (Mac OS X 10.14.4)]: Connected on socket dLE05r-TcFi8BxEHAAAA with id 2673721
HeadlessChrome 75.0.3738 (Mac OS X 10.14.4) ERROR
  {
    "message": "Uncaught Error: Cannot find module \"react-test-renderer/package.json\"\nat test/index.js:12553:180\n\nError: Cannot find module \"react-test-renderer/package.json\"\n    at webpackMissingModule (test/index.js:12553:81)\n    at Object.<anonymous> (test/index.js:12553:190)\n    at Object.<anonymous> (test/index.js:13513:31)\n    at __webpack_require__ (test/index.js:20:30)\n    at Object.<anonymous> (test/index.js:12519:19)\n    at __webpack_require__ (test/index.js:20:30)\n    at Object.<anonymous>(test/index.js:53:28)\n    at __webpack_require__ (test/index.js:20:30)\n    at test/index.js:40:18\n    at test/index.js:43:10",
    "str": "Uncaught Error: Cannot find module \"react-test-renderer/package.json\"\nat test/index.js:12553:180\n\nError: Cannot find module \"react-test-renderer/package.json\"\n    at webpackMissingModule (test/index.js:12553:81)\n    at Object.<anonymous> (test/index.js:12553:190)\n    at Object.<anonymous> (test/index.js:13513:31)\n    at __webpack_require__ (test/index.js:20:30)\n  at Object.<anonymous> (test/index.js:12519:19)\n    at __webpack_require__ (test/index.js:20:30)\n    at Object.<anonymous> (test/index.js:53:28)\n    at __webpack_require__ (test/index.js:20:30)\n    at test/index.js:40:18\n    at test/index.js:43:10"
  }

when I run karma start. “react”: “^16.1.0” “react-dom”: “^16.1.0” “react-test-renderer”: “^16.1.0”

I wonder if any can give us a clue on how to resolve this issue. Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MoAli2016commented, Apr 26, 2019

I bypassed test/index.js. Just went for the test files directly. I followed this link https://github.com/webpack-contrib/karma-webpack and got the tests passing. @ljharb very similar idea to your suggestion above. Added the code below to my karma.config.

    preprocessors: {
      'test/*_test.js': [ 'webpack' ],
      'test/**/*_test.js': [ 'webpack' ]
    },

    files: [{ pattern: 'test/*_test.js', watched: false }, { pattern: 'test/**/*_test.js', watched: false }],
1reaction
MoAli2016commented, Apr 26, 2019

Hi @ljharb, I set up the pattern { pattern: ‘test/**/*.json’, included: false, served: true} but still the error above persists. However, while running karma start all dependencies are built except one

./~/enzyme-adapter-react-16/build/ReactSixteenAdapter.js 92.1 kB {0} [built] [1 error]

I did not spotted this earlier. I guess this causes the error in the title of this post. Thank you for your help

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
I am getting the following error trace @ . ... enzyme adapter giving ERROR in ./~/react-test-renderer/package.json #2111.
Read more >
Enzyme expects an adapter to be configured - Stack Overflow
Error : TypeError: Adapter is not a constructor. I've grouped all the necessary steps in order to proper test your ReactJS component using...
Read more >
Build Youtube in React 06: Snapshot testing using Jest and ...
As we are using React 16.x we install the enzyme-adapter-react-16 component. Why do we also need the react-test-renderer package?
Read more >
enzyme-adapter-react-16 - npm
Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. You can also manipulate, traverse, ......
Read more >
Migrating from Enzyme to React Testing Library
It appears the key concern with React 18 is the async rendering feature, which would break a lot of the Enzyme library and...
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