Skip to content

Fix/cypress resizeobserver mock#11193

Open
AarishMansur wants to merge 2 commits intomarmelab:nextfrom
AarishMansur:fix/cypress-resizeobserver-mock
Open

Fix/cypress resizeobserver mock#11193
AarishMansur wants to merge 2 commits intomarmelab:nextfrom
AarishMansur:fix/cypress-resizeobserver-mock

Conversation

@AarishMansur
Copy link
Contributor

Problem

Cypress tests trigger the browser error:

ResizeObserver loop completed with undelivered notifications

This happens when components using ResizeObserver cause repeated resize cycles in the Cypress environment.

The current workaround suppresses this error using Cypress.on('uncaught:exception'). While this prevents test failures, it hides real issues and reduces the reliability of the test suite.

Solution

Replaced the error suppression workaround with a proper ResizeObserver mock.

  • Added a dedicated ResizeObserverMock utility that:

    • Implements the full ResizeObserver interface (observe, unobserve, disconnect)
    • Triggers callbacks asynchronously using requestAnimationFrame to avoid loops
    • Provides realistic contentRect values via getBoundingClientRect
    • Responds to window resize events to support responsive components
  • Injected the mock using Cypress.on('window:before:load') so it is available before the application initializes

  • Removed the uncaught:exception handler that was previously ignoring the error

  • Updated Cypress TypeScript configuration to properly support .js files and prevent emit conflicts

This ensures stable test execution while keeping error reporting accurate.

How To Test

  1. Run Cypress tests:

    yarn cypress run --spec cypress/e2e/list.cy.js
  2. Verify:

  • All tests pass successfully
  • No ResizeObserver loop completed... errors appear
  • No uncaught:exception suppression is present

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (not applicable this change affects test infrastructure only)
  • The PR includes one or several stories (not applicable no UI changes)
  • The documentation is up to date

Fixes : #10649

@AarishMansur AarishMansur force-pushed the fix/cypress-resizeobserver-mock branch from 54e66ab to 03da508 Compare March 18, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant