From 988a4fd77683bdb3b1515f972197d0d51045b175 Mon Sep 17 00:00:00 2001 From: Mohammer5 Date: Thu, 25 Apr 2024 09:20:52 +0800 Subject: [PATCH] chore(cypress): fix ResizeObserver loop error handling and make it global --- .cypress-cucumber-preprocessorrc.json | 3 ++- .../auto_hides_scroll_buttons/index.js | 20 ------------------- .../features/notify_at_end_of_list/index.js | 12 ----------- cypress/e2e/common.js | 11 ++++++++++ 4 files changed, 13 insertions(+), 33 deletions(-) create mode 100644 cypress/e2e/common.js diff --git a/.cypress-cucumber-preprocessorrc.json b/.cypress-cucumber-preprocessorrc.json index 3f586a22ed..4cd64d22e3 100644 --- a/.cypress-cucumber-preprocessorrc.json +++ b/.cypress-cucumber-preprocessorrc.json @@ -3,7 +3,8 @@ "e2e": { "stepDefinitions": [ "[filepath]/*.{js,mjs,ts,tsx}", - "[filepath]/../common/index.{js,mjs,ts,tsx}" + "[filepath]/../common/index.{js,mjs,ts,tsx}", + "cypress/e2e/common.js" ] } } diff --git a/components/tab/src/tab-bar/features/auto_hides_scroll_buttons/index.js b/components/tab/src/tab-bar/features/auto_hides_scroll_buttons/index.js index 022e5ae9d3..d27e1f26bd 100644 --- a/components/tab/src/tab-bar/features/auto_hides_scroll_buttons/index.js +++ b/components/tab/src/tab-bar/features/auto_hides_scroll_buttons/index.js @@ -1,25 +1,5 @@ -/* global before,after */ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor' -const handler = (err) => { - // > This error means that ResizeObserver was not able to deliver all - // > observations within a single animation frame. It is benign (your site - // > will not break). – Aleksandar Totic Apr 15 at 3:14 - // ----- - // https://stackoverflow.com/a/50387233 - if (err.message.match('ResizeObserver loop limit exceeded')) { - return false - } -} - -before(() => { - Cypress.on('uncaught:exception', handler) -}) - -after(() => { - Cypress.off('uncaught:exception', handler) -}) - Given('a tabbar with enough space for all tabs is rendered', () => { cy.viewport(1024, 768) cy.visitStory('TabBar', 'Scrollable with some tabs') diff --git a/components/transfer/src/features/notify_at_end_of_list/index.js b/components/transfer/src/features/notify_at_end_of_list/index.js index f67307021c..6f877ba3d8 100644 --- a/components/transfer/src/features/notify_at_end_of_list/index.js +++ b/components/transfer/src/features/notify_at_end_of_list/index.js @@ -1,17 +1,5 @@ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor' -Cypress.on('uncaught:exception', (err) => { - // This prevents a benign error: - // This error means that ResizeObserver was not able to deliver all - // observations within a single animation frame. It is benign (your site - // will not break). - // - // Source: https://stackoverflow.com/a/50387233/1319140 - if (err.match(/ResizeObserver loop limit exceeded/)) { - return false - } -}) - Given( 'the Transfer has enough items to fill the source list completely', () => { diff --git a/cypress/e2e/common.js b/cypress/e2e/common.js new file mode 100644 index 0000000000..6c3f33daa6 --- /dev/null +++ b/cypress/e2e/common.js @@ -0,0 +1,11 @@ +Cypress.on('uncaught:exception', (err) => { + // This prevents a benign error: + // This error means that ResizeObserver was not able to deliver all + // observations within a single animation frame. It is benign (your site + // will not break). + // + // Source: https://stackoverflow.com/a/50387233/1319140 + if (err.toString().match(/ResizeObserver loop limit exceeded/)) { + return false + } +})