From 062992a2e686ad809615d5a76b9ad0fe06729309 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Fri, 19 May 2023 12:50:48 +1200 Subject: [PATCH 1/2] check for testid in percySnapshotElement --- cypress/support/percy.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cypress/support/percy.ts b/cypress/support/percy.ts index ae35248789b..c01734f6ad1 100644 --- a/cypress/support/percy.ts +++ b/cypress/support/percy.ts @@ -47,6 +47,13 @@ Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subjec // Await inline spinners to vanish cy.get(".mx_InlineSpinner", { log: false }).should("not.exist"); } + + let selector = subject.selector; + // cy.findByTestId sets the selector to `findByTestId()` + // which is not usable as a scope + if (selector.startsWith("findByTestId")) { + selector = `[data-testid="${subject.attr("data-testid")}"]`; + } cy.percySnapshot(name, { domTransformation: (documentClone) => scope(documentClone, subject.selector), ...options, From df5660b33cbac0992c422c7dc50479fc369f1031 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 14 Jul 2023 12:31:18 +0100 Subject: [PATCH 2/2] Update percy.ts --- cypress/support/percy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/support/percy.ts b/cypress/support/percy.ts index c01734f6ad1..0b2c10c90ec 100644 --- a/cypress/support/percy.ts +++ b/cypress/support/percy.ts @@ -55,7 +55,7 @@ Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subjec selector = `[data-testid="${subject.attr("data-testid")}"]`; } cy.percySnapshot(name, { - domTransformation: (documentClone) => scope(documentClone, subject.selector), + domTransformation: (documentClone) => scope(documentClone, selector), ...options, }); });