You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/app/references/command-line.mdx
+11-77Lines changed: 11 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -598,86 +598,20 @@ Cypress Cloud will display any tags sent with the appropriate run.
598
598
599
599
#### Exit code
600
600
601
-
When Cypress finishes running tests, it exits. If there are no failed tests, the
602
-
exit code will be 0.
601
+
Cypress supports two different exit code behaviors. The default behavior is similar to that of Mocha, but is not POSIX compliant: reserved exit codes can be returned for certain conditions. As well, the default behavior
602
+
can return a false negative when there are a number of tests that fail in multiples of 255.
603
603
604
-
```text
605
-
## All tests pass
606
-
$ cypress run
607
-
...
608
-
Tests Passing Failing
609
-
✔ All specs passed! 00:16 17 17 0
604
+
POSIX compliant exit codes are available via the `--posix-exit-codes` flag. When this flag is passed, additional conditions can be returned that are not possible with the default behavior, including when Cypress fails due to
605
+
network errors when connections to Cypress Cloud are required, such as in`--record` or `--parallel` runs.
610
606
611
-
## print exit code on Mac or Linux
612
-
$ echo $?
613
-
0
614
-
```
615
-
616
-
By default, if there are any test failures, then the exit code will match the number of
617
-
tests that failed.
618
-
619
-
```text
620
-
## Spec with two failing tests
621
-
$ cypress run
622
-
...
623
-
Tests Passing Failing
624
-
✖ 1 of 1 failed (100%) 00:22 17 14 2
625
-
626
-
## print exit code on Mac or Linux
627
-
$ echo$?
628
-
2
629
-
```
630
-
631
-
You can change this behavior by passing the `--posix-exit-codes` flag. When this flag is passed,
632
-
the exit code will be 0 if all tests pass. If there are any test failures or if Cypress could not run,
633
-
the exit code will be 1.
634
-
635
-
```text
636
-
## Spec with two failing tests
637
-
$ cypress run --posix-exit-codes
638
-
...
639
-
Tests Passing Failing
640
-
✖ 1 of 1 failed (100%) 00:22 17 14 2
641
-
642
-
## print exit code on Mac or Linux
643
-
$ echo$?
644
-
1
645
-
```
646
-
647
-
When you use the `--posix-exit-codes` flag in a run that requires [Cypress Cloud](/cloud/get-started/introduction), and the Cypress application cannot communicate with the Cypress Cloud API due to a network error, the exit code will be `112`. Runs that use either `--record` or `--parallel` require communication with Cypress Cloud API.
648
-
649
-
```text
650
-
$ cypress run --posix-exit-codes --parallel --group=foo --ciBuildId=ciBuildId123
651
-
We encountered an unexpected error communicating with our servers.
607
+
When using POSIX compliant exit codes, the number of failed tests can be determined from [structured reporter data](/app/tooling/reporters).
652
608
653
-
RequestError: Error: ESOCKETTIMEDOUT
654
-
655
-
Because you passed the --parallel flag, this run cannot proceed since it requires a valid response from our servers.
656
-
657
-
The --group flag you passed was: foo
658
-
The --ciBuildId flag you passed was: ciBuildId123
659
-
660
-
$ echo$?
661
-
112
662
-
```
663
-
664
-
If Cypress could not run for some reason (for example if no spec files were
665
-
found) then the exit code will be 1.
666
-
667
-
```text
668
-
## No spec files found
669
-
$ cypress run --spec not-found.js
670
-
...
671
-
Can't run because no spec files were found.
672
-
673
-
We searched for any files matching this glob pattern:
0 commit comments