gpt4 book ai didi

reactjs - 如何在没有任何提示的情况下使用 Yarn 运行 Jest 测试?

转载 作者:行者123 更新时间:2023-12-03 13:34:03 25 4
gpt4 key购买 nike

我尝试在 Team City 中运行 Jest 单元测试,但最终总是收到如下所示的提示。

No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.

Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.

我尝试运行yarn test a来运行所有测试。但是,一旦测试完成执行,我仍然会收到相同的提示。我尝试了yarn test a q,但这不起作用。我还尝试了 yarn test a --forceExityarn test a --bail 但没有任何反应,我仍然收到提示。我如何运行所有 Jest 测试而不收到此提示,因为在 Team City 中运行时不会有交互?任何帮助将不胜感激。

最佳答案

--ci

当提供此选项时,Jest 将假定它正在 CI 环境中运行。这会改变遇到新快照时的行为。与自动存储新快照的常规行为不同,它会使测试失败并要求使用 --updateSnapshot 运行 Jest。 link

此外,您可以将 package.json 更改为:

"test": "CI=true react-scripts test --env=jsdom",

效果很好。

您的另一个选择是像任何变量一样在命令中设置CI:

CI=true yarn test

关于reactjs - 如何在没有任何提示的情况下使用 Yarn 运行 Jest 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51608998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com