react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Stack Overflow the ResizeObserver issue in Cypress

Open saloua-ch opened this issue 8 months ago • 0 comments

What you were expecting: Cypress tests should run cleanly, without throwing errors related to ResizeObserver. Right now, we’re relying on a workaround that just suppresses these errors, but ideally, we’d have a proper mock in place to handle the behavior correctly.

What happened instead: When running tests in Cypress, we’re seeing the error: “ResizeObserver loop completed with undelivered notifications.” To get around it, we’ve added a handler in cypress/support/index.js that catches and ignores the error using Cypress.on('uncaught:exception'). While this avoids test failures, it’s not a long-term fix and could mask real issues.

Steps to reproduce:

Run any test that uses components which trigger resize events (e.g., list.cy.js or edit.cy.js)

Open the Cypress test runner and look at the console output

Notice the ResizeObserver-related warning appearing but being caught and ignored

Related code: Here’s the current workaround in cypress/support/index.js:

js Copy Edit Cypress.on('uncaught:exception', err => { if ( err.message.includes( 'ResizeObserver loop completed with undelivered notifications' ) ) { return false; } }); Other information:

This is tied to known Cypress issues:

https://github.com/cypress-io/cypress/issues/20341

https://github.com/cypress-io/cypress/issues/29277

Ignoring the error avoids failing tests but isn't reliable or ideal

The better approach would be to mock ResizeObserver behavior properly

I’ve put together a working mock and plan to submit a PR with the fix soon

Environment:

React-admin version: [current version from package.json]

React version: [current version from package.json]

Browser: Chrome (via Cypress)

Stack trace: ResizeObserver loop completed with undelivered notifications

saloua-ch avatar Apr 09 '25 10:04 saloua-ch