Skip to content

Commit 752a27a

Browse files
chore: update code to exitCode in cy.exec() (#6247)
* chore: update code to exitCode * add history to exec * Add short migration descriptions * chore: fix linter issues --------- Co-authored-by: Jennifer Shehane <[email protected]> Co-authored-by: Jennifer Shehane <[email protected]>
1 parent 4d352eb commit 752a27a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

docs/api/commands/exec.mdx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Pass in an options object to change the default behavior of `cy.exec()`.
5757

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

60-
- `code`
60+
- `exitCode`
6161
- `stdout`
6262
- `stderr`
6363

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

9292
```javascript
93-
cy.exec('rake db:seed').its('code').should('eq', 0)
93+
cy.exec('rake db:seed').its('exitCode').should('eq', 0)
9494
```
9595

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

134134
```javascript
135135
cy.exec('man bear pig', { failOnNonZeroExit: false }).then((result) => {
136-
expect(result.code).to.eq(1)
136+
expect(result.exitCode).to.eq(1)
137137
expect(result.stderr).to.contain('No manual entry for bear')
138138
})
139139
```
@@ -237,6 +237,12 @@ the following:
237237
alt="console.log exec"
238238
/>
239239

240+
## History
241+
242+
| Version | Changes |
243+
| ------------------------------------------ | ------------------------------------- |
244+
| [15.0.0](/app/references/changelog#15-0-0) | Renamed property `code` to `exitCode` |
245+
240246
## See also
241247

242248
- [`cy.readFile()`](/api/commands/readfile)

docs/app/references/migration-guide.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ Cypress requires [Node.js](https://nodejs.org/en) in order to install the Cypres
2020
Node.js versions 18 and 23 are no longer supported.
2121
[See Node's release schedule](https://github.com/nodejs/Release).
2222

23+
### cy.exec code property renamed
24+
25+
The `code` property on [`cy.exec()`](/api/commands/exec) has been renamed to `exitCode`.
26+
27+
<Badge type="danger">Before</Badge>{' '}
28+
29+
```javascript
30+
cy.exec('rake db:seed').its('code').should('eq', 0)
31+
```
32+
33+
<Badge type="success">After</Badge>
34+
35+
```javascript
36+
cy.exec('rake db:seed').its('exitCode').should('eq', 0)
37+
```
38+
2339
### Unsupported Linux Distributions
2440

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

0 commit comments

Comments
 (0)