From d1e239c26fa0c6d37c1c817e25ef2525ced8e649 Mon Sep 17 00:00:00 2001 From: Michal Kulinski Date: Tue, 25 Oct 2022 12:19:20 +0200 Subject: [PATCH] Add forward compatibility with Cypress 10 --- src/utils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 649e11d..ae8a20f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -6,7 +6,10 @@ function getFirstElement(jqueryOrElement) { } function getContainer(container) { - const subject = cy.state('subject') + // Cypress 10 deprecated cy.state('subject') usage and suggest to use new cy.currentSubject. + // https://docs.cypress.io/guides/references/changelog#10-5-0 + // Below change ensures we do not get spam of warnings and are backward compatible with older cypress versions. + const subject = cy.currentSubject ? cy.currentSubject() : cy.state('subject'); const withinContainer = cy.state('withinSubject') if (!subject && withinContainer) {