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

Add “node” to Jest's moduleFileExtensions #2738

Merged
merged 1 commit into from Jul 7, 2017

Conversation

Projects
None yet
4 participants
@mostafah
Copy link
Contributor

commented Jul 7, 2017

Jest’s default value for its moduleFileExtensions option is ["js", "json", "jsx", "node"]. CRA was not using this option before version 1.0.8, so this default list was used.

PR #2511 (merged in version 1.0.8) sets this option to ["web.js", "js", "json", "web.jsx", "jsx"]. The PR is about adding .web extensions, but it is also removing .node because it is not included like other default extensions.

Why is this a bug?

Packages using native code through node-gyp import files with .node extension. Using those packages fails the tests with a Cannot find module … error.

screen shot 1396-04-16 at 10 09 13

This used to work with version 1.0.7.

Reproduction and testing

This repo is a minimal reproduction of this bug. Tests fail there. Changing react-scripts to 1.0.7 or manually applying this change to node_modules/react-scripts/scripts/utils/createJestConfig.js fixes the problem.

Add "node" to Jest's moduleFileExtensions
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

@gaearon gaearon added the tag: bug fix label Jul 7, 2017

@gaearon gaearon added this to the 1.0.11 milestone Jul 7, 2017

@gaearon gaearon merged commit 16f0d4a into facebook:master Jul 7, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gaearon

This comment has been minimized.

Copy link
Member

commented Jul 7, 2017

Thanks for the catch.
I guess it’s reasonable to support this, even though it wouldn’t work with webpack.

@mostafah

This comment has been minimized.

Copy link
Contributor Author

commented Jul 7, 2017

Thanks for the merge.

This is for projects that are using the same setup for the server. I have my backend code in src/server and take advantage of most of the CRA scripts for that.

@mostafah mostafah deleted the mostafah:jest-module-extensions branch Jul 7, 2017

romaindso added a commit to romaindso/create-react-app that referenced this pull request Jul 10, 2017

Add "node" to Jest's moduleFileExtensions (facebook#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.
@Timer

This comment has been minimized.

Copy link
Collaborator

commented Aug 9, 2017

Hi there! This change is out in react-scripts@1.0.11; please give it a go! Thanks.

@mostafah

This comment has been minimized.

Copy link
Contributor Author

commented Aug 9, 2017

Hi. I tested react-scripts@1.0.11 and it works. The bug is fixed. Thanks for the release and the reminder.

JohnNilsson referenced this pull request in JohnNilsson/create-react-app-typescript Aug 9, 2017

Add "node" to Jest's moduleFileExtensions (#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

connectdotz added a commit to connectdotz/create-react-app-typescript that referenced this pull request Aug 30, 2017

Add “node” to Jest's moduleFileExtensions
This is the same issue documented in react-script PR #2738 (facebook/create-react-app#2738), which has already been merged.

morgs32 added a commit to BrickworkSoftware/create-react-app that referenced this pull request Sep 1, 2017

Add "node" to Jest's moduleFileExtensions (facebook#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

JohnNilsson referenced this pull request in JohnNilsson/create-react-app-typescript Sep 9, 2017

Add "node" to Jest's moduleFileExtensions (#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

kasperpeulen added a commit to kasperpeulen/create-react-app that referenced this pull request Sep 24, 2017

Add "node" to Jest's moduleFileExtensions (facebook#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

swengorschewski referenced this pull request in swengorschewski/cra-typescript-electron Oct 16, 2017

Add "node" to Jest's moduleFileExtensions (#2738)
Jest's default value for this option is ["js", "json", "jsx", "node"].
CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which
is missing one of default ones: "node". This change fixes that.

This "node" extension is used in packages that use native code.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.