Skip to content

Commit 495c869

Browse files
committed
chore(cypress): fix ResizeObserver loop error handling and make it global
1 parent 022154d commit 495c869

File tree

4 files changed

+18
-33
lines changed

4 files changed

+18
-33
lines changed

.cypress-cucumber-preprocessorrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"e2e": {
44
"stepDefinitions": [
55
"[filepath]/*.{js,mjs,ts,tsx}",
6-
"[filepath]/../common/index.{js,mjs,ts,tsx}"
6+
"[filepath]/../common/index.{js,mjs,ts,tsx}",
7+
"cypress/e2e/common.js"
78
]
89
}
910
}

components/tab/src/tab-bar/features/auto_hides_scroll_buttons/index.js

-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
/* global before,after */
21
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
32

4-
const handler = (err) => {
5-
// > This error means that ResizeObserver was not able to deliver all
6-
// > observations within a single animation frame. It is benign (your site
7-
// > will not break). – Aleksandar Totic Apr 15 at 3:14
8-
// -----
9-
// https://stackoverflow.com/a/50387233
10-
if (err.message.match('ResizeObserver loop limit exceeded')) {
11-
return false
12-
}
13-
}
14-
15-
before(() => {
16-
Cypress.on('uncaught:exception', handler)
17-
})
18-
19-
after(() => {
20-
Cypress.off('uncaught:exception', handler)
21-
})
22-
233
Given('a tabbar with enough space for all tabs is rendered', () => {
244
cy.viewport(1024, 768)
255
cy.visitStory('TabBar', 'Scrollable with some tabs')

components/transfer/src/features/notify_at_end_of_list/index.js

-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
22

3-
Cypress.on('uncaught:exception', (err) => {
4-
// This prevents a benign error:
5-
// This error means that ResizeObserver was not able to deliver all
6-
// observations within a single animation frame. It is benign (your site
7-
// will not break).
8-
//
9-
// Source: https://stackoverflow.com/a/50387233/1319140
10-
if (err.match(/ResizeObserver loop limit exceeded/)) {
11-
return false
12-
}
13-
})
14-
153
Given(
164
'the Transfer has enough items to fill the source list completely',
175
() => {

cypress/e2e/common.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Cypress.on('uncaught:exception', (err) => {
2+
/* This prevents a benign error:
3+
* This error means that ResizeObserver was not able to deliver all
4+
* observations within a single animation frame. It is benign (your site
5+
* will not break).
6+
*
7+
* Source: https://stackoverflow.com/a/50387233/1319140
8+
*/
9+
const errMsg = err.toString()
10+
if (
11+
errMsg.match(/ResizeObserver loop limit exceeded/) ||
12+
errMsg.match(/ResizeObserver loop completed with undelivered notifications/)
13+
) {
14+
return false
15+
}
16+
})

0 commit comments

Comments
 (0)