Skip to content

Commit eae360d

Browse files
authored
feat: add cy.exec() Cypress 15 misc test compatibility (#984)
* feat: add cy.exec() Cypress 15 misc test compatibility * remove dependency on semver * lint format fix
1 parent 0f2b7ad commit eae360d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/commands/misc.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ <h4 id="exec"><a href="https://on.cypress.io/exec">cy.exec()</a></h4>
129129
.its('stderr').should('be.empty')
130130

131131
cy.exec('pwd')
132-
.its('code').should('eq', 0)
132+
// for Cypress 14 and below, use 'code' instead of 'exitCode'
133+
.its('exitCode').should('eq', 0)
133134
}</code></pre>
134135
</div>
135136

cypress/e2e/2-advanced-examples/misc.cy.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ context('Misc', () => {
4848
cy.exec(`cat ${Cypress.config('configFile')}`)
4949
.its('stderr').should('be.empty')
5050

51-
cy.exec('pwd')
52-
.its('code').should('eq', 0)
51+
cy.log(`Cypress version ${Cypress.version}`)
52+
if (Cypress.version.split('.').map(Number)[0] < 15) {
53+
cy.exec('pwd')
54+
.its('code').should('eq', 0)
55+
}
56+
else {
57+
cy.exec('pwd')
58+
.its('exitCode').should('eq', 0)
59+
}
5360
}
5461
})
5562

0 commit comments

Comments
 (0)