Skip to content
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

MutationRecord should be globally available #1112

Closed
wojtekmaj opened this issue Oct 3, 2023 · 3 comments
Closed

MutationRecord should be globally available #1112

wojtekmaj opened this issue Oct 3, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@wojtekmaj
Copy link
Contributor

Describe the bug

MutationRecord should be globally available, as it is in the browser.

To Reproduce

I have a test in my test suite that checks if MutationObserver callback gets called with an array of MutationRecord. Because it's not globally available, this test code:

    expect(listener).toHaveBeenCalledWith(
      [expect.any(MutationRecord)],
      expect.any(MutationObserver),
    );

is, in reality,

    expect(listener).toHaveBeenCalledWith(
      [expect.any(undefined)],
      expect.any(MutationObserver),
    );

and results in an error:

TypeError: any() expects to be passed a constructor function. Please pass one or use anything() to match any object.

As a temporary workaround, I can to import it manually into my module:

import MutationRecord from 'happy-dom/lib/mutation-observer/MutationRecord.js';

and it works just fine.

Expected behavior

MutationRecord to be globally available.

Screenshots

Commit with tests failing after replacing JSDom with Happy DOM:
wojtekmaj/react-hooks@8a95c2b

@wojtekmaj wojtekmaj added the bug Something isn't working label Oct 3, 2023
wojtekmaj added a commit to wojtekmaj/react-hooks that referenced this issue Oct 3, 2023
@capricorn86
Copy link
Owner

Thank you for reporting @wojtekmaj! 🙂

This has been fixed now.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v12.8.0

@capricorn86 capricorn86 self-assigned this Oct 3, 2023
@wojtekmaj
Copy link
Contributor Author

Haha seeing notifications from you always feels like Christmas, it's always good news. :D

Have a beer on me! 🍺

@capricorn86
Copy link
Owner

Thank you @wojtekmaj! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants