run-ct returns with exit code 0 when tests fail - breaking CI detection of failed tests
See original GitHub issueCurrent behavior
This is a pretty big bug. All CI jobs running with run-ct
will report success even if tests fail due to this bug.
In this screenshot, you are seeing the output of yarn cypress:component:cli --spec=packages/SearchInput/src/component_tests/ClearButton.test.tsx
which runs this command:
"cypress:component:cli": "cypress run-ct --project integration-tests",
Note that at the bottom, we see Done in 69.93s
but no error. This Done
is reported by yarn. When a test fails, it should look more like this (I added expect(false).toBe(true)
to a jest test to simulate a failure):
cypress.json:
{
"baseUrl": "http://localhost:6009",
"retries": {
"runMode": 2,
"openMode": 0
},
"integrationFolder": "../packages",
"testFiles": "**/integration_tests/*.test.tsx",
"component": {
"componentFolder": "../packages",
"testFiles": "**/component_tests/*.test.tsx"
}
}
Desired behavior
when a test fails, the shell error code should be non-zero. cypress run
does this correctly.
Test code to reproduce
- write a failing component test
- run it with
cypress run-ct
- watch to see that the exit code is 0
Cypress Version
8.3.0
Other
tested with 7.6.0
as well, upgraded to be sure it was not already fixed.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:31 (11 by maintainers)
Top Results From Across the Web
Getting Exit Code = 0 when one test failed - Katalon Community
I have a test that has been failing for some time already, starting today, it still fails, yet exit code is 0 instead...
Read more >Changelog - Cypress Documentation
Sessions will no longer be stored if validation fails which will prevent a previously failed session from being restored in the next test....
Read more >python - Unit test script returns exit code = 0 even if tests fail
The code is not using unittest.main . You need to check the result using TestResult.wasSuccessful and call sys.exit manually.
Read more >TeamCity On-Premises - Build Failure Conditions - JetBrains
The if the build process exit code is not zero condition allows failing a build if the build process doesn't exit successfully.
Read more >How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. ... when a test fails. You'll be happy to have something to look at when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wonder if somewhere in the release and test pipeline a tool like https://github.com/bahmutov/cypress-expect could be used to verify the failing tests and the exit code
excellent, thank you, I’ll report back shortly, probably a few hours once these meetings are dun