Reputation: 1599
When I run the command jest --bail --findRelatedTests src/components/BannerSet/BannerSet.tsx
I get the following message:
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in C:\Users\user\code\repo.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: .\\src\\components\\BannerSet\\BannerSet.tsx - 0 matches
However I do have the files ready:
src/components/BannerSet/BannerSet.test.tsx
src/components/BannerSet/BannerSet.tsx
Why cant Jest find the related tests? Running just jest
works perfectly fine.
Upvotes: 6
Views: 2931
Reputation: 181
If you are using the roots
configuration ensure you include your source directory in the list of folders.
I ran into this issue and found it was because I was using the roots
option in my jest configuration and was only referencing the test
folder. The below issue and roots documentation point out:
roots is used by the internals of Jest to locate test files and source files
Related information:
Upvotes: 1