question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run-ct returns with exit code 0 when tests fail - breaking CI detection of failed tests

See original GitHub issue

Current 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",
Screen Shot 2021-08-16 at 3 12 44 PM

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):

Screen Shot 2021-08-16 at 3 18 30 PM

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

  1. write a failing component test
  2. run it with cypress run-ct
  3. 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:31 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Aug 25, 2021

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

1reaction
cellogcommented, Aug 25, 2021

excellent, thank you, I’ll report back shortly, probably a few hours once these meetings are dun

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found