Skip to content
New issue

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

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

Already on GitHub? # to your account

Cannot find module 'react-test-renderer/package' from 'ReactSixteenAdapter.js' #2046

Closed
12 tasks
doronpr opened this issue Mar 13, 2019 · 11 comments
Closed
12 tasks

Comments

@doronpr
Copy link

doronpr commented Mar 13, 2019

Current behavior

Cannot find module 'react-test-renderer/package' from 'ReactSixteenAdapter.js'
Broke in 98154a9
Changing the import from:
import { version as testRendererVersion } from 'react-test-renderer/package';
to
import { version as testRendererVersion } from 'react-test-renderer';

Solves the issue for me.

Expected behavior

No error...

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.9.0
react 16.8.4
react-dom 16.8.4
react-test-renderer 16.8.4
adapter (below)

Adapter

  • [x ] enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@youluna
Copy link

youluna commented Mar 13, 2019

We had the same problem: https://travis-ci.com/alibaba-fusion/next/builds/104198552#L667

doronpr added a commit to doronpr/enzyme that referenced this issue Mar 13, 2019
@zombieJ
Copy link
Contributor

zombieJ commented Mar 13, 2019

Got the same error: https://circleci.com/gh/ant-design/ant-design/63215?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

@shpyo

This comment has been minimized.

@andreyshuster

This comment has been minimized.

@vzhukovsky

This comment has been minimized.

@ipanasenko
Copy link

Just freeze it to ~1.10.0 for now. No need to write "same here" 100500 times

@ljharb
Copy link
Member

ljharb commented Mar 13, 2019

This shouldn’t break for anyone - node supports importing json files without an extension.

If it’s not working, then your environment is broken.

@srittau
Copy link

srittau commented Mar 13, 2019

Adding "json" to jest.moduleFileExtensions in our package.json file works around this problem. Still, I consider it a bug in enzyme-adapter-react-16 to require this configuration.

@ljharb
Copy link
Member

ljharb commented Mar 13, 2019

Considering that's the default configuration of node itself, it's a bug in your jest configuration.

@srittau if you remove your fix to your jest config, and change the import in the adapter to have an explicit .json extension, does that fix the issue for you?

@srittau
Copy link

srittau commented Mar 13, 2019

@ljharb It does.

I admit that it makes sense for enzyme to expect to be able to include things without extension, according to node's default configuration. I believe the root problem is that jest does not have an option to add to the default list of file extensions in package.json, just to replace it. But I think enzyme can help maintainers by changing the import of the json file (a not too common case) to include the suffix.

We now opted to remove jest.moduleFileExtensions, since all extensions required by us are now contained in jest's default configuration anyway.

@ljharb
Copy link
Member

ljharb commented Mar 13, 2019

Either way, I'll close this issue by explicitly adding the extension, since that seems to be the best compromise.

ljharb added a commit that referenced this issue Mar 13, 2019
 - [fix] add an explicit `.json` extension (#2048, #2046)
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

9 participants