简体   繁体   English

赛普拉斯测试偶尔失败

[英]Cypress Tests Fail Sporadically

We have been debugging failing cypress tests for a few days now and cannot seem to narrow down the cause.几天来,我们一直在调试失败的 cypress 测试,似乎无法缩小原因。 The tests run in our GitLab CICD pipeline.测试在我们的 GitLab CICD 管道中运行。

Error we see in the logs:我们在日志中看到的错误:

Uncaught (in promise): TypeError: Cannot convert undefined or null to object\\nTypeError: Cannot convert undefined or null to object\\n at Function.keys ()\\n at MapSubscriber.project (http://localhost:49152/main.2e49092b1a3db7b9c078.js:8506:28)\\n at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next ...未捕获(承诺中):TypeError:无法将 undefined 或 null 转换为对象\\nTypeError:无法在 MapSubscriber.project (http://localhost:49152/main. 2e49092b1a3db7b9c078.js:8506:28)\\n 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next ...

We added a cypress plugin to rerun the any test if they fail and it always passes the second time.我们添加了一个 cypress 插件来重新运行任何测试,如果它们失败并且它总是第二次通过。 It is not the same test that fails each time, it varies.每次都失败的不是同一个测试,它会有所不同。 The failure seems to happen because a page fails to render due to the error above but it is unclear what that error is from.失败似乎是因为页面由于上述错误而无法呈现,但尚不清楚该错误来自何处。

We have noticed the tests pass in Firefox so we are only seeing this error in headless chrome/chromium based browsers.我们注意到测试在 Firefox 中通过,所以我们只在基于无头 chrome/chromium 的浏览器中看到这个错误。

Any ideas what we could look at to find out what's going wrong?有什么想法可以让我们找出问题所在吗?

We were able to get a more helpful error after adding a logging package to Cypress for our front end.在为我们的前端向 Cypress 添加日志包后,我们能够得到一个更有用的错误。

error (network): Failed to load resource: net::ERR_INSUFFICIENT_RESOURCES错误(网络):无法加载资源:net::ERR_INSUFFICIENT_RESOURCES

Our issue turns out to be an open issue with Cypress where Chrome is eating up too much memory and crashing Docker.我们的问题被证明是 Cypress 的一个未解决的问题,其中 Chrome 占用了太多内存并导致 Docker 崩溃。

Issue and resolution are posted here: https://github.com/cypress-io/cypress/issues/7457问题和解决方法发布在这里: https : //github.com/cypress-io/cypress/issues/7457

Follow https://docs.cypress.io/guides/guides/continuous-integration.html#In-Docker and then setting --ipc=host on our docker containers [will] stop the issue.按照https://docs.cypress.io/guides/guides/continuous-integration.html#In-Docker然后在我们的 docker 容器上设置 --ipc=host [将] 停止问题。

After digging a little, adding --disable-dev-shm-usage flag to chrome solve the issue for me.经过一番挖掘后,将--disable-dev-shm-usage标志添加到 chrome 为我解决了这个问题。 You can use --ipc=host but the isolation is better without it.您可以使用--ipc=host但没有它隔离会更好。

I encountered the same issue with Karma and Chrome >= 90 in Docker.我在 Docker 中遇到了与 Karma 和 Chrome >= 90 相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM