Ale*_*ack 37 reactjs jestjs redux create-react-app
更新:我的用例主要是在CI上运行测试,但是重写默认的CRA Jest参数是我一般想知道的.
我正在使用Create React App附带的Jest,config 运行测试.它始终启动到交互模式:
› Press a to run all tests.
› Press o to only run tests related to changed files.
› Press p to filter by a filename regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.
Run Code Online (Sandbox Code Playgroud)
但我不希望它等待我的意见.我希望它运行一次然后终止.我尝试使用--bail或--no-watchman开关,但它仍然以交互模式启动.
如果我全局安装jest,并在我的项目的根目录中运行它,它执行一次并完成(就像我想要的那样).但是当我运行npm test哪个运行时react-scripts test,即使我没有通过,它也会进入监视模式--watch.
更新:我还在CRA上提出了一个问题.
thi*_*ign 17
在您的package.json脚本中:
"test": "react-scripts test --watchAll=false"
或者 npm test -- --watchAll=false
或者 yarn test --watchAll=false
注意:使用的标志被称为--no-watch在react-scripts < 3.0:https://github.com/facebook/create-react-app/blob/3.x/CHANGELOG.md#remove---no-watch-flag
| 归档时间: |
|
| 查看次数: |
6445 次 |
| 最近记录: |