简体   繁体   中英

Cypress Tests Fail Sporadically

We have been debugging failing cypress tests for a few days now and cannot seem to narrow down the cause. The tests run in our GitLab CICD pipeline.

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 ...

We added a cypress plugin to rerun the any test if they fail and it always passes the second time. 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.

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.

error (network): Failed to load resource: 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.

Issue and resolution are posted here: 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.

After digging a little, adding --disable-dev-shm-usage flag to chrome solve the issue for me. You can use --ipc=host but the isolation is better without it.

I encountered the same issue with Karma and Chrome >= 90 in Docker.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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