Skip to content

chore: update code to exitCode in cy.exec() #6247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions docs/api/commands/exec.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Pass in an options object to change the default behavior of `cy.exec()`.

`cy.exec()` yields an object with the following properties:

- `code`
- `exitCode`
- `stdout`
- `stderr`

Expand All @@ -80,7 +80,7 @@ is great for:
cy.exec('npm run build').then((result) => {
// yields the 'result' object
// {
// code: 0,
// exitCode: 0,
// stdout: "Files successfully built",
// stderr: ""
// }
Expand All @@ -90,7 +90,7 @@ cy.exec('npm run build').then((result) => {
#### Seed the database and assert it was successful

```javascript
cy.exec('rake db:seed').its('code').should('eq', 0)
cy.exec('rake db:seed').its('exitCode').should('eq', 0)
```

#### Run an arbitrary script and assert its output
Expand Down Expand Up @@ -133,7 +133,7 @@ cy.exec('npm run build', { timeout: 20000 })

```javascript
cy.exec('man bear pig', { failOnNonZeroExit: false }).then((result) => {
expect(result.code).to.eq(1)
expect(result.exitCode).to.eq(1)
expect(result.stderr).to.contain('No manual entry for bear')
})
```
Expand Down Expand Up @@ -237,6 +237,12 @@ the following:
alt="console.log exec"
/>

## History

| Version | Changes |
| ------------------------------------------ | ------------------------------------- |
| [15.0.0](/app/references/changelog#15-0-0) | Renamed property `code` to `exitCode` |

## See also

- [`cy.readFile()`](/api/commands/readfile)
Expand Down
1 change: 0 additions & 1 deletion docs/app/references/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ sidebar_label: Changelog

_Released 7/29/2025 (PENDING)_


## 14.5.4

_Released 8/07/2025_
Expand Down
16 changes: 16 additions & 0 deletions docs/app/references/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ Cypress requires [Node.js](https://nodejs.org/en) in order to install the Cypres
Node.js versions 18 and 23 are no longer supported.
[See Node's release schedule](https://github.com/nodejs/Release).

### cy.exec code property renamed

The `code` property on [`cy.exec()`](/api/commands/exec) has been renamed to `exitCode`.

<Badge type="danger">Before</Badge>{' '}

```javascript
cy.exec('rake db:seed').its('code').should('eq', 0)
```

<Badge type="success">After</Badge>

```javascript
cy.exec('rake db:seed').its('exitCode').should('eq', 0)
```

### Unsupported Linux Distributions

Prebuilt binaries for Linux are no longer compatible with Linux distributions based on glibc `<2.31`.
Expand Down