https://github.com/paularmstrong/jest-multi-project-example
https://github.com/paularmstrong/jest-multi-project-example
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/paularmstrong/jest-multi-project-example
- Owner: paularmstrong
- Created: 2018-04-24T15:06:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-06T06:33:23.000Z (over 7 years ago)
- Last Synced: 2025-05-06T22:09:09.166Z (5 months ago)
- Language: JavaScript
- Size: 35.2 KB
- Stars: 15
- Watchers: 2
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Yarn Workspaces with Jest Multiple Projects
## Setup
1. `yarn` to install dependencies and link workspaces
2. `yarn test` to ensure tests work correctly## Reproducing The Issue
In this example, we would like to see the following happen:
1.Run `yarn test --findRelatedTests --listTests projects/bar/bar.js` (`test` is a package script shortcut to `jest`)
### 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.