Skip to content
28 changes: 27 additions & 1 deletion docs/app/references/command-line.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ cypress run [options]
| `--no-runner-ui` | [Hides the Cypress Runner UI](#cypress-run-no-runner-ui) |
| `--parallel` | [Run recorded specs in parallel across multiple machines](#cypress-run-parallel) |
| `--port`,`-p` | [Override default port](#cypress-run-port-lt-port-gt) |
| `--posix-exit-codes` | [Exit with a POSIX-compliant exit code](#cypress-run-posix-exit-codes) rather than the number of failed tests. |
| `--project`, `-P` | [Path to a specific project](#cypress-run-project-lt-project-path-gt) |
| `--quiet`, `-q` | [Reduce output to `stdout`](#cypress-run-quiet) |
| `--record` | [Whether to record the test run](#cypress-run-record-key-lt-record-key-gt) |
Expand Down Expand Up @@ -439,6 +440,14 @@ documentation to learn more.
cypress run --port 8080
```

#### `cypress run --posix-exit-codes` {#cypress-run-posix-exit-codes}

Exit with POSIX exit code of 1 when there are test failures or if Cypress could not run.

```shell
cypress run --posix-exit-codes
```

Comment on lines 443 to 450
Copy link
Contributor

@MikeMcC399 MikeMcC399 Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe cross-link here to the section #Exit-code?

I completely missed this section when I glanced at the change 🤭

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Updated here 524b211

#### `cypress run --project <project-path>` {#cypress-run-project-lt-project-path-gt}

To see this in action we've set up an
Expand Down Expand Up @@ -602,7 +611,7 @@ $ echo $?
0
```

If there are any test failures, then the exit code will match the number of
By default, if there are any test failures, then the exit code will match the number of
tests that failed.

```text
Expand All @@ -617,6 +626,22 @@ $ echo $?
2
```

You can change this behavior by passing the `--posix-exit-codes` flag. When this flag is passed,
the exit code will be 0 if all tests pass. If there are any test failures or if Cypress could not run,
the exit code will be 1.

```text
## Spec with two failing tests
$ cypress run --posix-exit-codes
...
```

```text
## print exit code on Mac or Linux
Comment on lines 638 to 642
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...
```
```text
## print exit code on Mac or Linux
...
## print exit code on Mac or Linux

Merge into one code block like the other examples above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

$ echo $?
1
```

If Cypress could not run for some reason (for example if no spec files were
found) then the exit code will be 1.

Expand Down Expand Up @@ -975,6 +1000,7 @@ and with Windows CMD and PowerShell terminal windows.

| Version | Changes |
| ------------------------------------------ | ---------------------------------------------------------- |
| [15.4.0](/app/references/changelog#15-4-0) | Added `--posix-exit-codes` flag to `cypress run` |
| [12.6.0](/app/references/changelog#12-6-0) | Added `--auto-cancel-after-failures` flag to `cypress run` |
| [5.4.0](/app/references/changelog) | Added `prune` subcommand to `cypress cache` |
| [5.4.0](/app/references/changelog) | Added `--size` flag to `cypress cache list` subcommand |
Expand Down