reactjs - Jest --findRelatedTests 没有找到相关的测试
问题描述
当我运行命令时,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
工作得很好。
解决方案
如果您正在使用roots
配置,请确保将源目录包含在文件夹列表中。
我遇到了这个问题,发现这是因为我roots
在我的 jest 配置中使用了该选项,并且只引用了该test
文件夹。以下问题和根文档指出:
Jest 内部使用roots来定位测试文件和 源文件
相关信息:
推荐阅读
- javascript - XXX 不是 JavaScript 中的函数
- python - 如何在 python 中实现 API.AI 机器人?
- python - Python 2.7 Pyautogui.locateOnScreen 不工作
- jenkins - Jenkins - 如何将测试日志复制回工件目录以进行构建
- c# - 访问当前从 gmail 邮箱发送/接收的邮件
- c++ - C++ 和标准容器:成员的内存地址
- r - 无法为签名 '"NULL"' 的函数 'lhs<-' 找到继承的方法
- c++ - Boost MSM 开启当前状态
- postgresql - 将 DBMS_OUTPUT.PUT_LINE 结果发送到 Postgres 中的外部文件
- java - 编译jar项目maven eclipse时出错