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

Don't ignore node_modules #7145

Closed
RuneKR opened this issue Oct 12, 2018 · 7 comments
Closed

Don't ignore node_modules #7145

RuneKR opened this issue Oct 12, 2018 · 7 comments

Comments

@RuneKR
Copy link

RuneKR commented Oct 12, 2018

Hi,

This is basically a replica of: #1995 (comment)

Whenever you structure your project packages/node_modules/**/* the test doesn't get picked up. Have a fix been implemented via a config? I cannot find the solution at least

My project is organised:

  • package.json
  • node_modules
    • .bin
    • jest
  • packages
    • node_modules
      • .bin (symlink)
      • @scope
        • packename
          • package.json
        • packagename
        • ...

Tests can be run if i run the tests from the root package.json but not from any of the package.json under packages/node_modules/. If i rename packages/node_modules to anything else then it works.

@reklatsmasters
Copy link

You can unignore some folders inside node_modules using this undocumented options:

"haste": {
  "providesModuleNodeModules": [
    "package-inside-node_modules-1",
    "package-inside-node_modules-2",
  ]
},

Also, if you want to collect coverage, use this solution: #5046 (comment).

@RuneKR
Copy link
Author

RuneKR commented Oct 14, 2018

Hi, thank you! I am still a little bit uncertain on how exactly to use this.

Which package.json should i add the configuration to and how to add it?
Is haste a configuration under jest in the package.json file?

@RuneKR
Copy link
Author

RuneKR commented Oct 14, 2018

I found a solution now, just ignore my previous question. Thank you @reklatsmasters ! I am not sure that i should close the issue yet as the haste config should really be documented.

Might just raise a PR for that.

So the "solution" was to do what you @reklatsmasters suggested. I am quite new to working with JEST so i didn't realise the heavy caching that jest is doing for us. For future reference. Every time one make a configuration change like this, just remember to run jest with --clearcache.

@RuneKR
Copy link
Author

RuneKR commented Oct 20, 2018

I guess this is partly documented in: https://jestjs.io/docs/en/tutorial-react-native#providesmodule so i'll close for now

@RuneKR RuneKR closed this as completed Oct 20, 2018
@Ghazgkull
Copy link

@RuneKR Can you please share what you figured out to answer your questions above? As someone trying to get coverage for the source in my lib/node_modules directory, I have the same questions. What do I need to add to my package.json configuration and where does it go? :)

@RuneKR
Copy link
Author

RuneKR commented Jan 10, 2019

Hi sure thing!

I need to know a bit more about your project in order to provide the right code.

I have my configuration in the package.json:

"jest": {
 "haste": {
  "providesModuleNodeModules": [
    "package-inside-node_modules-1",
    "package-inside-node_modules-2",
  ],
 "coveragePathIgnorePatterns": [ "<rootdir>/node_modules"]
 ...
},
 

@github-actions
Copy link

This issue 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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants