jest: [bug] findRelatedTests misses tests, especially in multi-project setups
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Here’s an absolute minimal repo that explains this same test case and can be run directly: https://github.com/paularmstrong/jest-multi-project-example
- Clone the repo at https://github.com/paularmstrong/jest-multi-project-example
- Run
yarn
to install dependencies - Run
yarn test
to ensure tests run - Run
yarn test --findRelatedTests --listTests projects/bar/bar.js
(test
is a package script shortcut tojest
)
Expectation
We should expect to see the following files as related in the output:
projects/bar/__tests__/index.test.js
projects/foo/__tests__/index.test.js
Actual results
Jest does not appear to resolve related changes across project configurations and we do no receive any listed tests.
Alternatively
If we run yarn test --findRelatedTests --listTests projects/bar/index.js
, we do receive only the file for the direct project, bar
.
projects/bar/__tests__/index.test.js
Why this is problematic
This is a problem because if we are in a sufficiently large project with many workspaces and many interdependencies, we may make a change to one file in a single workspace and expect to be able to run only the related tests for that change, but none will be run.
We could argue that we should just run all tests, but this can take too long (15+ minutes) to realistically ask people to do every time they make a change.
Environment
Environment:
OS: macOS High Sierra 10.13.4
Node: 8.11.1
Yarn: 1.6.0
npm: 5.6.0
Watchman: 4.7.0
Xcode: Xcode 8.1 Build version 8B62
Android Studio: Not Found
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 15 (5 by maintainers)
That sounds like a workable solution! I have some time next week to look in and attempt this if you’re not already planning on it.