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

fix: Allow searching for tests in node_modules #11084

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

cjr125
Copy link
Contributor

@cjr125 cjr125 commented Feb 13, 2021

Summary

In order to be able to inherit a common Jest test from an npm module, the user needs to be able to search for tests in the node_modules directory. The boolean "retainAllFiles" had been hard-coded to false, preventing this inheritance from being possible. The changes here expose the variable via the "haste" configuration property and allow the user to optionally scan the node_modules for test patterns.

Test plan

$ npx jest --testRegex "/*(.pact.test.js)" --runInBand
 PASS  test/src/Health.pact.test.js (9.646 s)
 PASS  node_modules/@aw/node-testing/dist/test/health.pact.test.js (5.922 s)

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        15.733 s
Ran all test suites.

@facebook-github-bot
Copy link
Contributor

Hi @cjr125!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@cjr125 cjr125 force-pushed the review/retainAllFiles branch 2 times, most recently from 76b1fc1 to 9e5be59 Compare February 13, 2021 22:01
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@cjr125 cjr125 force-pushed the review/retainAllFiles branch from 9e5be59 to 68e6841 Compare February 13, 2021 22:11
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@cjr125 cjr125 force-pushed the review/retainAllFiles branch 7 times, most recently from ec15331 to 26efe98 Compare February 18, 2021 00:17
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

@cjr125 Hi, sorry I missed this PR!

Could you rebase it (or just merge in main if you prefer) and add an integration test actually running a test in node_modules? You can add a "fake" node_modules and just git add --force it

docs/Configuration.md Outdated Show resolved Hide resolved
@cjr125 cjr125 force-pushed the review/retainAllFiles branch 2 times, most recently from 763c204 to ed832d3 Compare February 22, 2022 00:59
@SimenB
Copy link
Member

SimenB commented Feb 22, 2022

Thanks! Test is failing on CI, in case you missed it 🙂

@cjr125 cjr125 force-pushed the review/retainAllFiles branch 2 times, most recently from 504f99d to 213ce11 Compare February 22, 2022 12:08
@cjr125 cjr125 force-pushed the review/retainAllFiles branch from 213ce11 to a23b663 Compare February 22, 2022 12:09
@cjr125 cjr125 force-pushed the review/retainAllFiles branch from a23b663 to 0d1c05e Compare February 22, 2022 12:27
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

thanks!

@SimenB SimenB changed the title fix: Allow searching for tests in node_modules fix: Allow searching for tests in node_modules Feb 22, 2022
@SimenB SimenB merged commit 491e7cb into jestjs:main Feb 22, 2022
@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 Mar 25, 2022
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.

[Bug]: Unable to run a test from whitelisted "node_modules" Jest not running tests in src/node_modules
4 participants