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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With