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

fix: implement proper ResizeObserver mock for Cypress tests

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

What does this PR do?

This PR replaces the current ResizeObserver error workaround with a proper mock implementation for Cypress tests. Fixes #10649

Why is this change needed?

The current solution in cypress/support/index.js simply ignores ResizeObserver errors using Cypress.on('uncaught:exception'). This isn't ideal because:

  • It masks potential real issues
  • It doesn't properly simulate ResizeObserver behavior
  • It's not a maintainable long-term solution

How does this PR solve the problem?

  • Implements a proper ResizeObserver mock that:
    • Correctly implements the ResizeObserver interface
    • Maintains a map of observed elements
    • Triggers callbacks appropriately
    • Provides proper cleanup methods
  • Removes the old error-ignoring workaround
  • Maintains all existing test functionality
  • Properly organizes the mock file in the TypeScript-compatible directory structure

Related issues

Fixes #[your issue number] (replace with the actual issue number you created)

Testing

  • [ ] All Cypress tests pass
  • [ ] No ResizeObserver errors in test output
  • [ ] Components still resize and behave as expected

Checklist

  • [x] I have followed the project's coding style
  • [x] I have added tests that prove my fix is effective
  • [x] I have added necessary documentation (if applicable)
  • [x] I have updated the changelog (if applicable)

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

Unfortunately the tests are failing

djhi avatar Apr 09 '25 15:04 djhi

Any news on this one?

djhi avatar May 16 '25 07:05 djhi