Skip to content

Commit 08024c9

Browse files
docs: adds --posix-exit-codes cli flag for run mode (#6284)
* adds --posix-exit-codes cli flag for run mode * add history entry * clarify option/description table for --posix-exit-codes * expand docs on posix exit codes * prettify bash block * fix changelog link * formatting * Add posixExitCodes to module API page * changelog * lint fix --------- Co-authored-by: Jennifer Shehane <[email protected]> Co-authored-by: Jennifer Shehane <[email protected]>
1 parent 9026eb0 commit 08024c9

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

docs/app/references/changelog.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ sidebar_label: Changelog
88

99
# Changelog
1010

11+
## 15.4.0
12+
13+
_Released 10/07/2025_
14+
1115
## 15.3.0
1216

1317
_Released 9/23/2025_

docs/app/references/command-line.mdx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ cypress run [options]
217217
| `--no-runner-ui` | [Hides the Cypress Runner UI](#cypress-run-no-runner-ui) |
218218
| `--parallel` | [Run recorded specs in parallel across multiple machines](#cypress-run-parallel) |
219219
| `--port`,`-p` | [Override default port](#cypress-run-port-lt-port-gt) |
220+
| `--posix-exit-codes` | [Exit with a POSIX-compliant exit code](#cypress-run-posix-exit-codes) rather than the number of failed tests. |
220221
| `--project`, `-P` | [Path to a specific project](#cypress-run-project-lt-project-path-gt) |
221222
| `--quiet`, `-q` | [Reduce output to `stdout`](#cypress-run-quiet) |
222223
| `--record` | [Whether to record the test run](#cypress-run-record-key-lt-record-key-gt) |
@@ -439,6 +440,16 @@ documentation to learn more.
439440
cypress run --port 8080
440441
```
441442
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+
442453
#### `cypress run --project <project-path>` {#cypress-run-project-lt-project-path-gt}
443454
444455
To see this in action we've set up an
@@ -602,7 +613,7 @@ $ echo $?
602613
0
603614
```
604615
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
606617
tests that failed.
607618
608619
```text
@@ -617,6 +628,22 @@ $ echo $?
617628
2
618629
```
619630
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+
620647
If Cypress could not run for some reason (for example if no spec files were
621648
found) then the exit code will be 1.
622649
@@ -975,6 +1002,7 @@ and with Windows CMD and PowerShell terminal windows.
9751002
9761003
| Version | Changes |
9771004
| ------------------------------------------ | ---------------------------------------------------------- |
1005+
| [15.4.0](/app/references/changelog#15-4-0) | Added `--posix-exit-codes` flag to `cypress run` |
9781006
| [12.6.0](/app/references/changelog#12-6-0) | Added `--auto-cancel-after-failures` flag to `cypress run` |
9791007
| [5.4.0](/app/references/changelog) | Added `prune` subcommand to `cypress cache` |
9801008
| [5.4.0](/app/references/changelog) | Added `--size` flag to `cypress cache list` subcommand |

docs/app/references/module-api.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Just like the [Command Line options](/app/references/command-line) for
7777
| `exit` | _boolean_ | Whether to close Cypress after all tests run |
7878
| `parallel` | _boolean_ | Run recorded specs in [parallel](/cloud/features/smart-orchestration/parallelization) across multiple machines |
7979
| `port` | _number_ | Override default port |
80+
| `posixExitCodes` | _boolean_ | Exit with a POSIX-compliant exit code rather than the number of failed tests. |
8081
| `project` | _string_ | Path to a specific project |
8182
| `quiet` | _boolean_ | If passed, Cypress output will not be printed to `stdout`. Only output from the configured [Mocha reporter](/app/tooling/reporters) will print. |
8283
| `record` | _boolean_ | Whether to record the test run |
@@ -367,6 +368,7 @@ node ./wrapper cypress run --browser chrome --config ...
367368

368369
| Version | Changes |
369370
| ------------------------------------------ | ------------------------------------------------------- |
371+
| [15.4.0](/app/references/changelog#15-4-0) | Added `posixExitCodes` to run options. |
370372
| [12.6.0](/app/references/changelog#12-6-0) | Added `autoCancelAfterFailures` to run options. |
371373
| [10.0.0](/app/references/changelog#10-0-0) | `slowTestThreshold` is now scoped to each testing type. |
372374
| [8.7.0](/app/references/changelog#8-7-0) | Added `slowTestThreshold` configuration option. |

0 commit comments

Comments
 (0)