Skip to content

Commit

Permalink
Ignore ResizeObserver errors in Cypress tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
undergroundwires committed Apr 3, 2024
1 parent 5d940b5 commit a0dcd67
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/e2e/support/e2e.ts
Expand Up @@ -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'),
);

0 comments on commit a0dcd67

Please sign in to comment.