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

Use NODE_PATH env var in jest config #1272

Closed
wants to merge 2 commits into from

Conversation

EnoahNetzach
Copy link
Contributor

Fixes #1271.

@@ -38,6 +38,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'
],
moduleDirectories: ['node_modules', process.env.NODE_PATH].filter(dir => dir),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we exclude absolute paths here like we do in env.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean from process.env.NODE_PATH?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. See #1194 for context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course!

@EnoahNetzach EnoahNetzach force-pushed the jest-node-path branch 2 times, most recently from ec49e72 to 0ac094e Compare December 21, 2016 09:55
@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Hmm, this makes me confused. Isn't Jest already supposed to handle NODE_PATH? If mocking doesn't work it might be a Jest issue.

Also, I think this file would execute after ejecting, causing directory names to get hardcoded into package.json. I don't think it's the desired effect.

Copy link
Contributor

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works as intended (see my comment).

@gor181
Copy link

gor181 commented Jun 26, 2017

This seems to work out of the box with react-scripts@1.0.7.
The line we have in is:

"test": "NODE_PATH=src react-scripts test --env=jsdom",

So I assume this can be closed?

@gaearon
Copy link
Contributor

gaearon commented Jun 26, 2017

Yep, it's been fixed. Thanks for reminding!

@gaearon gaearon closed this Jun 26, 2017
@EnoahNetzach EnoahNetzach deleted the jest-node-path branch June 26, 2017 16:27
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants