这就是我在不重新启动测试的情况下对特定文件动态运行测试的方式。
我的 React 项目创建为create-react-app
.
所以它监视测试的变化,当我做出改变时自动运行测试。
所以这就是我在终端测试结果结束时看到的:
Test Suites: 16 passed, 16 total
Tests: 98 passed, 98 total
Snapshots: 0 total
Time: 5.048s
Ran all test suites.
Watch Usage: Press w to show more.
按W
Watch Usage
› Press f to run only failed tests.
› Press o to only run tests related to changed files.
› Press q to quit watch mode.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press Enter to trigger a test run.
然后按P
Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to filter by a filenames regex pattern.
pattern ›
Start typing to filter by a filename regex pattern.
这是在我想在“登录”文件夹中运行“index.es6.js”文件之后:
Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to filter by a filenames regex pattern.
pattern › login/index
Pattern matches 1 file
› src/containers/Login/index.es6.test.js
这就是我在特定文件上运行测试的方式。