Skip to content

Commit

Permalink
chore(cypress): fix ResizeObserver loop error handling and make it gl…
Browse files Browse the repository at this point in the history
…obal
  • Loading branch information
Mohammer5 committed Apr 25, 2024
1 parent 3eee474 commit 8b47655
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .cypress-cucumber-preprocessorrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
12 changes: 0 additions & 12 deletions components/transfer/src/features/notify_at_end_of_list/index.js
Original file line number Diff line number Diff line change
@@ -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',
() => {
Expand Down
16 changes: 16 additions & 0 deletions cypress/e2e/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
*/
const errMsg = err.toString()
if (
errMsg.match(/ResizeObserver loop limit exceeded/) ||
errMsg.match(/ResizeObserver loop completed with undelivered notifications/)
) {
return false
}
})

0 comments on commit 8b47655

Please sign in to comment.