Skip to content

fix: implement proper ResizeObserver mock for Cypress tests #10650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saloua-ch
Copy link

@saloua-ch saloua-ch commented Apr 9, 2025

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

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

@djhi
Copy link
Collaborator

djhi commented Apr 9, 2025

Unfortunately the tests are failing

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.

Stack Overflow the ResizeObserver issue in Cypress
2 participants