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

WIP: haste ignores using testPathIgnorePatterns, not all node_modules #2318

Closed

Conversation

modernserf
Copy link

Summary
An attempt to fix the issue raised in #2145, which is blocking facebook/create-react-app#1081.

Test plan

This PR is incomplete because this test is failing; furthermore, I should introduce a test that fails in master but works in this PR to illustrate the feature it solves.

I need some help with this.

@rovansteen
Copy link

I've tried to work on this a bit but I'm not completely sure how this one is supposed to look? Is this supposed to work 'out of the box' or do we require some configuration? @gaearon was pushing to make the use of src/node_modules an official solution for this problem (facebook/create-react-app#1065) so it might make sense to make Jest work with that 'official solution' by default. But curious to hear what the Jest folks think about it.

@modernserf
Copy link
Author

@cpojer can you or someone else knowledgeable about haste help me out on this? I don't really understand how to get the tests passing here.

@@ -672,10 +672,7 @@ class HasteMap extends EventEmitter {
* Helpers
*/
_ignore(filePath: Path): boolean {
return (
this._options.ignorePattern.test(filePath) ||
(!this._options.retainAllFiles && this._isNodeModulesDir(filePath))
Copy link
Member

Choose a reason for hiding this comment

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

we cannot remove this option as we are using it at FB.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead maybe we could add config.testPathIgnorePatterns to this._whitelist?

@rovansteen
Copy link

@cpojer could you reply to my comment? (#2318 (comment)) I'd love to work on this pull request but I'm not sure if you want this to work out of the box or should be configurable.

@cpojer
Copy link
Member

cpojer commented Dec 26, 2016

I think making retainAllFiles configurable through the haste config field in Jest makes sense and should potentially work. If not, we'll have to find something else solution.

I honestly don't know yet what the right solution should really be as I haven't had time to think about it beyond pointing out that the solution in this PR is not appropriate. It would be best to pick this up sometime after New Years, as I'm on vacation right now.

@julien-f
Copy link

julien-f commented Jan 4, 2017

IMHO, only testPathIgnorePatterns should be needed: using <rootDir> or anchoring it at the start (^/node_modules/) should be enough.

Another approach could be to use .gitignore files.

@cpojer
Copy link
Member

cpojer commented Jan 8, 2017

Did anybody else have thoughts on this? As is, this PR isn't a good solution.

@rovansteen
Copy link

rovansteen commented Jan 12, 2017

I agree with @julien-f that adding testPathIgnorePatterns to the config like this:

"testPathIgnorePatterns": [
  "<rootDir>/(node_modules)/"
]

should be enough to make sure Jest runs the tests inside any node_modules folder elsewhere and transpile it.

@cpojer
Copy link
Member

cpojer commented Jan 12, 2017

@julien-f and @rovansteen are you saying this is already working?

@julien-f
Copy link

@cpojer No it's not, it's how it should work IMHO :)

@julien-f
Copy link

julien-f commented Jan 12, 2017

But the more I think about it, the more I think it should by default uses .gitignore :)

@cpojer
Copy link
Member

cpojer commented Jan 12, 2017

I'm happy if somebody makes a PR that makes that work. This one doesn't yet, though.

@cpojer
Copy link
Member

cpojer commented Jan 12, 2017

I don't think that is appropriate, @julien-f. Not every project uses git, for example we use hg at Facebook.

@julien-f
Copy link

Fair enough :)

@julien-f
Copy link

@cpojer Is this fixed?

@cpojer
Copy link
Member

cpojer commented Apr 12, 2017

No it isn't yet and we haven't made any progress on this in a while. It doesn't seem like this PR isn't being worked on right now.

@julien-f
Copy link

Ok, thank you.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
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.

6 participants