Cypress e2e tests are failing on CI but not locally

Hi, what are the most common reasons why the e2e tests will fail on CircleCi and not locally? This has only been happening recently and not sure why.

1 Like

Thanks for joining the CircleCI community!

It would be helpful to see the errors you are getting to identify what could be going on. Can you post them here?

1 Like

Hello,
This shows where the e2e tests are failing: https://app.circleci.com/pipelines/github/Unirep/Unirep-Social/421/workflows/f95e99dc-bf2b-44ea-b2a8-29c90a919a69/jobs/2613

You can also clone down this repo and checkout to the branch where the tests are failing and see that the e2e tests pass locally and fail on the CI.

You can also find the CI config here: Unirep-Social/config.yml at main Ā· Unirep/Unirep-Social Ā· GitHub

Thanks for responding!

@jerdog any thoughts here?

The only real error I am seeing is coming from the application code for landing.cy.ts

TypeError: The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.

It working locally but not in your CI pipeline usually means a dependency isnā€™t accounted for somewhere?

I think this has to be a dependency issue. But still debugging.

1 Like

Hey @AnthonyMadia , just wanted to follow up and see how things are coming along?

Thanks for following up. I solved this problem but now having the same problem on another branch. It seems the CI is having flaky tests but I can run everything perfectly locally.

This is strange because the changes made on this branch were very minimal as you can see here: Frontend/show off rep bar by kittybest Ā· Pull Request #145 Ā· Unirep/Unirep-Social Ā· GitHub but the e2e tests are still failing.

I donā€™t know enough about Cypress, but the errors it spits out seem to be pretty specific around ā€œunhandled promiseā€. Running things locally and working, but not working in the CI platform (which is containerized) usually points to dependency issues.

How did you solve the previous problem?

I have the same issue. My tests run fine locally and most of them run fine in CI, however, my one test that calls an external API fails. Here is the error Iā€™m seeing:

TypeError: Cannot read properties of undefined (reading ā€˜statusCodeā€™)
at Context.eval (webpack:///./cypress/e2e/spec.cy.js:98:37)

I saw this same error locally when my API call was failing. I was able to determine this by using my chrome developer tools / network tab. Is there a way to access this (Dev Tools) in CircleCI. While Iā€™m asking, is there a way for me to access my backend server logs on CircleCI as well? Iā€™m new to CircleCI