由于缺少颜色,github动作中的开玩笑快照测试失败

发布于 2025-01-30 09:30:21 字数 578 浏览 2 评论 0原文

我在试图设置一个运行Jest Test Suite的GitHub动作时遇到了问题。它 fails>由于使用SnapShots而言。似乎问题可能是由于错误消息上的彩色格式引起的。

提供的屏幕截图是因为我无法使用仅使用Markdown复制到此问题的颜色格式。

测试全部通过本地通过,所以我知道逻辑有效。这是GitHub测试跑步者中的问题,但我不确定如何解决。如果我删除这些特定的测试,它将删除我的代码覆盖范围。如何在这种环境中获得测试?

I am having an issue while trying to set up a Github action that runs my Jest test suite. It fails due to using snapshots. It appears the issue might be caused by the colored formatting on the error messages.

Screenshot provided because I couldn't get the color formatting to copy over to this question using only markdown.

The tests all pass locally, so I know the logic works. It is an issue in the Github test runner, but I'm not sure how to address it. If I remove those particular tests, it will drop my code coverage. How do I get the tests to pass in this environment?

CI/CD environment showing where test fails

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘心安 2025-02-06 09:30:21

假设您使用npm test运行测试,则可以设置环境变量force_color,从而在github action中发出开玩笑的颜色:

- run: npm test
  env:
    FORCE_COLOR: true

Assuming you run your tests with npm test, you can set the environment variable FORCE_COLOR and thereby make jest use color in GitHub Actions as well:

- run: npm test
  env:
    FORCE_COLOR: true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文