@@ -217,6 +217,7 @@ cypress run [options]
217
217
| ` --no-runner-ui ` | [ Hides the Cypress Runner UI] ( #cypress-run-no-runner-ui ) |
218
218
| ` --parallel ` | [ Run recorded specs in parallel across multiple machines] ( #cypress-run-parallel ) |
219
219
| ` --port ` ,` -p ` | [ Override default port] ( #cypress-run-port-lt-port-gt ) |
220
+ | ` --posix-exit-codes ` | [ Exit with a POSIX exit code] ( #cypress-run-posix-exit-codes ) |
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,14 @@ 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
+ Exit with POSIX exit code of 1 when there are test failures or if Cypress could not run.
446
+
447
+ ```shell
448
+ cypress run --posix-exit-codes
449
+ ```
450
+
442
451
#### `cypress run --project <project-path>` {#cypress-run-project-lt-project-path-gt}
443
452
444
453
To see this in action we' ve set up an
@@ -602,7 +611,7 @@ $ echo $?
602
611
0
603
612
```
604
613
605
- If there are any test failures, then the exit code will match the number of
614
+ By default, if there are any test failures, then the exit code will match the number of
606
615
tests that failed.
607
616
608
617
```text
@@ -617,6 +626,22 @@ $ echo $?
617
626
2
618
627
```
619
628
629
+ You can change this behavior by passing the `--posix-exit-codes` flag. When this flag is passed,
630
+ the exit code will be 0 if all tests pass. If there are any test failures, or if Cypress could not run,
631
+ the exit code will be 1.
632
+
633
+ ```text
634
+ ## Spec with two failing tests
635
+ $ cypress run --posix-exit-codes
636
+ ...
637
+ ```
638
+
639
+ ```text
640
+ ## print exit code on Mac or Linux
641
+ $ echo $?
642
+ 1
643
+ ```
644
+
620
645
If Cypress could not run for some reason (for example if no spec files were
621
646
found) then the exit code will be 1.
622
647
0 commit comments