Ignore ResizeObserver errors in Cypress tests

This commit addresses false negative failures in Cypress due to a known
Chrome issue.

The included change prevents Cypress tests from failing because of the
non-critical `ResizeObserver loop limit exceeded` error, which occurs
inconsistently during CI/CD runs with GitHub runners. This error has
been documented in CHrome and does not affect actual browser usage or
local test runs. This commit implements a widely recommended workaround
that ignores this specific error during test execution.

Error from Cypress:

```
Error: The following error originated from your application code, not from Cypress.
> ResizeObserver loop limit exceeded
```

The solution follows community-driven advice and past discussions on
handling this benign exception within test scenarios. It contributes to
more reliable CI/CD results by filtering out irrelevant error noise.

For detailed background and discussion on this error, see:

- Cypress issues: cypress-io/cypress#8418, cypress-io/cypress#20341
- Cypress PRs: cypress-io/cypress#20257, cypress-io/cypress#20284
- Discussion in Quasar: quasarframework/quasar#2233
- Discussion in specification repository: WICG/resize-observer#38
This commit is contained in:
undergroundwires
2024-04-04 10:02:37 +02:00
parent 5d940b57ef
commit 4472c2852e

View File

@@ -4,3 +4,27 @@
*/
import './commands';
// Mitigates a Chrome-specific 'ResizeObserver' error in Cypress tests.
// The 'ResizeObserver loop limit exceeded' error is non-critical but can cause
// false negatives in CI/CD environments, particularly with GitHub runners.
// The issue is absent in actual browser usage and local Cypress testing.
// Community discussions and contributions have led to this handler being
// recommended as a user-level fix rather than a Cypress core inclusion.
// Relevant discussions and attempted core fixes:
// - Original fix suggestion: https://github.com/cypress-io/cypress/issues/8418#issuecomment-992564877
// - Proposed Cypress core PRs:
// https://github.com/cypress-io/cypress/pull/20257
// https://github.com/cypress-io/cypress/pull/20284
// - Current issue tracking: https://github.com/cypress-io/cypress/issues/20341
// - Related Quasar framework issue: https://github.com/quasarframework/quasar/issues/2233
// - Chromium bug tracker discussion: https://issues.chromium.org/issues/41369140
// - Stack Overflow on safely ignoring the error:
// https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded/50387233#50387233
// https://stackoverflow.com/questions/63653605/resizeobserver-loop-limit-exceeded-api-is-never-used/63653711#63653711
// - Spec issue related to 'ResizeObserver': https://github.com/WICG/resize-observer/issues/38
Cypress.on(
'uncaught:exception',
// Ignore this specific error to prevent false test failures
(err) => !err.message.includes('ResizeObserver loop limit exceeded'),
);