Skip to content

Commit 8882e41

Browse files
authored
Add forward compatibility with Cypress 10 (#233)
1 parent dcfa412 commit 8882e41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ function getFirstElement(jqueryOrElement) {
66
}
77

88
function getContainer(container) {
9-
const subject = cy.state('subject')
9+
// Cypress 10 deprecated cy.state('subject') usage and suggest to use new cy.currentSubject.
10+
// https://docs.cypress.io/guides/references/changelog#10-5-0
11+
// Below change ensures we do not get spam of warnings and are backward compatible with older cypress versions.
12+
const subject = cy.currentSubject ? cy.currentSubject() : cy.state('subject');
1013
const withinContainer = cy.state('withinSubject')
1114

1215
if (!subject && withinContainer) {

0 commit comments

Comments
 (0)