Fix: cypress `findByTestId` and `percySnapshotElement` do not work together (#10947)
* check for testid in percySnapshotElement * Update percy.ts --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>pull/28788/head^2
parent
63bdd84c94
commit
eced103458
|
@ -47,8 +47,15 @@ Cypress.Commands.add("percySnapshotElement", { prevSubject: "element" }, (subjec
|
||||||
// Await inline spinners to vanish
|
// Await inline spinners to vanish
|
||||||
cy.get(".mx_InlineSpinner", { log: false }).should("not.exist");
|
cy.get(".mx_InlineSpinner", { log: false }).should("not.exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let selector = subject.selector;
|
||||||
|
// cy.findByTestId sets the selector to `findByTestId(<testId>)`
|
||||||
|
// which is not usable as a scope
|
||||||
|
if (selector.startsWith("findByTestId")) {
|
||||||
|
selector = `[data-testid="${subject.attr("data-testid")}"]`;
|
||||||
|
}
|
||||||
cy.percySnapshot(name, {
|
cy.percySnapshot(name, {
|
||||||
domTransformation: (documentClone) => scope(documentClone, subject.selector),
|
domTransformation: (documentClone) => scope(documentClone, selector),
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue