12
更新:我的用例主要是在CI上运行测试,但覆盖默认CRA Jest参数是我一般想知道的。在非交互模式下运行CRA Jest
我使用Jest,配置与Create React App来运行测试。它始终启动到交互模式:
› 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.
但我不希望它等待我的输入。我希望它运行一次然后终止。我尝试使用--bail
或--no-watchman
交换机,但仍以交互模式启动。
如果我全局安装jest
,并在我的项目的根目录下运行它,它会执行一次并完成(就像我想的那样)。但是当我运行npm test
运行react-scripts test
时,即使我没有通过--watch
,它也会进入手表模式。
更新:我也在CRA上提交了一个问题。
你可以看到它的确认[这里](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/scripts/test.js#L25) – wgcrouch
yes ,就这个问题而言,没有更简单的方法:https://github.com/facebookincubator/create-react-app/issues/784 – AlexStack