I'm running e2e tests with cypress on GitLab. here is the command I run to run Cypress tests:
docker-compose -f devops/e2e/docker-compose.yml up cypress
Cypress service is simply based on cypress/included:8.4.0 image.
So in my Gitlab job when the tests succeed I get something like this:
cypress | Spec Tests Passing Failing Pending Skipped
cypress | ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
cypress | │ ✔ login_spec.js 00:04 1 1 - - - │
cypress | ├────────────────────────────────────────────────────────────────────────────────────────────────┤
cypress | │ ✔ multi_resolution_image_spec.js 00:41 1 1 - - - │
cypress | ├────────────────────────────────────────────────────────────────────────────────────────────────┤
cypress | │ ✔ plain_image_spec.js 00:40 1 1 - - - │
cypress | ├────────────────────────────────────────────────────────────────────────────────────────────────┤
cypress | │ ✔ signup_spec.js 00:10 1 1 - - - │
cypress | └────────────────────────────────────────────────────────────────────────────────────────────────┘
cypress | ✔ All specs passed! 01:36 4 4
cypress exited with code 0
.
.
.
Job succeeded
But when the tests fail I get:
cypress | Spec Tests Passing Failing Pending Skipped
cypress | ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
cypress | │ ✖ annotate_spec.js 00:02 1 - 1 - - │
cypress | ├────────────────────────────────────────────────────────────────────────────────────────────────┤
cypress | │ ✔ login_spec.js 00:05 1 1 - - - │
cypress | ├────────────────────────────────────────────────────────────────────────────────────────────────┤
cypress | │ ✔ signup_spec.js 00:13 1 1 - - - │
cypress | └────────────────────────────────────────────────────────────────────────────────────────────────┘
cypress | ✖ 1 of 3 failed (33%) 00:21 3 2 1
cypress exited with code 1
.
.
.
Job succeeded
The problem is in case of failure of run tests I'm still getting Job succeeded from Gitlab. How can I make Gitlab CI runner get its exit code from cypress service exit code?
You can try use option --exit-code-from:
docker-compose -f devops/e2e/docker-compose.yml up --exit-code-from cypress
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With