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

Angular Testing Library with combination of HappyDom instead of JSDOM #440

Open
jarekcimoch opened this issue Feb 28, 2024 · 3 comments
Open

Comments

@jarekcimoch
Copy link

Hello, I'm using HappyDom instead of JSDOM and I have following issue.

when I do something like
await screen.findByText(optionLabel);

observer.observe is not a function TypeError: observer.observe is not a function

at C:\Ohpen\cloned-2\mfes-broker-app-angular\src\node_modules\@testing-library\dom\dist\wait-for.js:96:16

HappyDom is supporting MutationObserver and I guess JSDOM was not out of the box hance some logic there is used.
Could it be fixed? Or can I fix it somehow myself?

@timdeschryver
Copy link
Member

We expect the tests to be run in a DOM-like environment.
This also means that there's a MutationObserver observer available to react to dom changes.
A workaround is to run all tests in a "fake timers context", which doesn't use the observer.

@jarekcimoch
Copy link
Author

@timdeschryver HappyDom is DOM-like env, it has MutiationObserver in place

@timdeschryver
Copy link
Member

@jarekcimoch do you have a reproduction that I can use to test this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants