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
|`--posix-exit-codes`|[Exit with a POSIX-compliant exit code](#cypress-run-posix-exit-codes) rather than the number of failed tests. |
220
221
|`--project`, `-P`|[Path to a specific project](#cypress-run-project-lt-project-path-gt)|
221
222
|`--quiet`, `-q`|[Reduce output to `stdout`](#cypress-run-quiet)|
222
223
|`--record`|[Whether to record the test run](#cypress-run-record-key-lt-record-key-gt)|
@@ -439,6 +440,16 @@ documentation to learn more.
439
440
cypress run --port 8080
440
441
```
441
442
443
+
#### `cypress run --posix-exit-codes` {#cypress-run-posix-exit-codes}
444
+
445
+
This changes the default behavior of Cypress regarding exit codes. This flag causes Cypress to exit with POSIX exit code of 1 when there are test failures or if Cypress could not run, rather than the number of tests that failed.
446
+
447
+
```shell
448
+
cypress run --posix-exit-codes
449
+
```
450
+
451
+
For more about Cypress'exit code behavior, see the [Exit Code section](/app/references/command-line#Exit-code).
452
+
442
453
#### `cypress run --project <project-path>` {#cypress-run-project-lt-project-path-gt}
443
454
444
455
To see this in action we've set up an
@@ -602,7 +613,7 @@ $ echo $?
602
613
0
603
614
```
604
615
605
-
If there are any test failures, then the exit code will match the number of
616
+
By default, if there are any test failures, then the exit code will match the number of
606
617
tests that failed.
607
618
608
619
```text
@@ -617,6 +628,22 @@ $ echo $?
617
628
2
618
629
```
619
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
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
+
620
647
If Cypress could not run for some reason (for example if no spec files were
621
648
found) then the exit code will be 1.
622
649
@@ -975,6 +1002,7 @@ and with Windows CMD and PowerShell terminal windows.
Copy file name to clipboardExpand all lines: docs/app/references/module-api.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,7 @@ Just like the [Command Line options](/app/references/command-line) for
77
77
|`exit`|_boolean_| Whether to close Cypress after all tests run |
78
78
|`parallel`|_boolean_| Run recorded specs in [parallel](/cloud/features/smart-orchestration/parallelization) across multiple machines |
79
79
|`port`|_number_| Override default port |
80
+
|`posixExitCodes`|_boolean_| Exit with a POSIX-compliant exit code rather than the number of failed tests. |
80
81
|`project`|_string_| Path to a specific project |
81
82
|`quiet`|_boolean_| If passed, Cypress output will not be printed to `stdout`. Only output from the configured [Mocha reporter](/app/tooling/reporters) will print. |
82
83
|`record`|_boolean_| Whether to record the test run |
0 commit comments