我有针对 dockerized Neo4j 数据库运行的 Jest 测试,有时它们在 CircleCI 上失败。所有 25 个以上的错误消息是:
thrown: "Exceeded timeout of 5000 ms for a hook.
@*******api: Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
由于它们有时会失败,例如每 25 次运行一次,我想知道 jest.setTimeout
是否会解决该问题。我能够通过设置 jest.setTimeout(10)
在本地使它们失败,但我不确定如何进一步调试它,或者除了小超时之外是否还有其他问题(默认 5000)。如果 1/25 或少数失败,或者所有其他套装都失败,我会理解,但只有一个包含该文件中所有测试的文件失败。而且它始终是同一个文件,因此永远不会是其他文件。
附加信息,在本地,单个文件在连接到临时数据库的时间内运行不到 1000 毫秒,与运行时只有几个文件的 dockerized 相比,这是巨大的
I have Jest tests that are running against the dockerized Neo4j Database, and sometimes they fail on CircleCI. The error message for all 25+ of them is :
thrown: "Exceeded timeout of 5000 ms for a hook.
@*******api: Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
Since they fail sometimes, like once in 25 runs, I am wondering if jest.setTimeout
will solve the issue. I was able to fail them locally by setting jest.setTimeout(10)
, but I am not sure how to debug this even more, or whether something else could be an issue here aside from a small timeout (default 5000). I would understand if 1/25 or a few fails, or if all other suits fail, but only a single file with all tests within that file is failing. And it is always the same file, never some other file for this reason ever.
Additional information, locally, that single file runs in less than a 1000ms connected to the staging database which is huge compared to the dockerized that has only a few files at the time of running
发布评论
评论(2)
对于看到此问题的任何人,我可以通过在 CircleCI 配置中的测试命令中添加
--maxWorkers=2
标志来解决此问题。有关详细信息,请参阅此处:https://support.circleci.com/hc/en-us/articles/360005442714-Your-test-tools-are-smart-and-that-sa-problem-Learn-about-when-优化-出错-For anyone who sees this, I was able to solve this by adding the
--maxWorkers=2
flag to the test command in my CircleCI config. See here for details: https://support.circleci.com/hc/en-us/articles/360005442714-Your-test-tools-are-smart-and-that-s-a-problem-Learn-about-when-optimization-goes-wrong-纳曼的回答很完美!我简直不敢相信,但这确实解决了我的问题。只是为了更加清楚如何执行此操作:
我将
package.json
中的test
脚本从jest
更改为jest - -maxWorkers=2
。然后我推了一下,它确实解决了我的错误。Naman's answer is perfect! I couldn't believe it but it really solved my problem. Just to be extra clear on how to do it:
I change the
test
script from mypackage.json
fromjest
tojest --maxWorkers=2
. Then I pushed and it did solve my error.