From 4d79c86870e31fd468894a09cfb0c0f149c5cf4a Mon Sep 17 00:00:00 2001 From: Logan Graham Date: Tue, 1 Oct 2024 08:18:25 -0400 Subject: [PATCH] [Cypress] Allow multiple elements in ignoreRegions (#145) Co-authored-by: Logan Graham --- visual-js/.changeset/old-mails-sin.md | 5 +++++ visual-js/visual-cypress/src/commands.ts | 16 +++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 visual-js/.changeset/old-mails-sin.md diff --git a/visual-js/.changeset/old-mails-sin.md b/visual-js/.changeset/old-mails-sin.md new file mode 100644 index 00000000..e27c1a33 --- /dev/null +++ b/visual-js/.changeset/old-mails-sin.md @@ -0,0 +1,5 @@ +--- +"@saucelabs/cypress-visual-plugin": patch +--- + +fix ignore regions for multiple elements diff --git a/visual-js/visual-cypress/src/commands.ts b/visual-js/visual-cypress/src/commands.ts index da2c3f31..4288dd52 100644 --- a/visual-js/visual-cypress/src/commands.ts +++ b/visual-js/visual-cypress/src/commands.ts @@ -92,19 +92,13 @@ function chainableWaitForAll( ): Cypress.Chainable { const result: S[] = []; - if (list.length < 1) return cy.wrap([]); - - let curChainable = list[0]; - for (let idx = 1; idx < list.length; idx++) { - curChainable = curChainable.then((resolved) => { - result.push(resolved); - return list[idx]; + list.forEach((item) => { + item.then((el) => { + result.push(el); }); - } - return curChainable.then((item) => { - result.push(item); - return result; }); + + return cy.wrap(result); } const sauceVisualCheckCommand = (