【发布时间】:2020-05-22 08:08:59
【问题描述】:
当我运行命令 jest --bail --findRelatedTests src/components/BannerSet/BannerSet.tsx
时,我收到以下消息:
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
但是我确实已经准备好了文件:
src/components/BannerSet/BannerSet.test.tsx
src/components/BannerSet/BannerSet.tsx
为什么 Jest 找不到相关的测试?只运行 jest 就可以了。
【问题讨论】:
-
你试过了吗?
jest pathoffile -
如果我提供测试文件就可以了,但这不是我想要的。因为我想让 Jest 找到给定组件的相关测试
-
然后你可以把
__tests__文件夹中的所有测试文件放到自动拾取。 -
您找到解决方案了吗?
标签: reactjs typescript jestjs