-
Notifications
You must be signed in to change notification settings - Fork 92
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
When using user.click
in @testing-library/angular
, an error is thrown
#103
When using user.click
in @testing-library/angular
, an error is thrown
#103
Comments
I'm pretty sure it's failing here: I'm not sure what the |
Here's the code for that: https://unpkg.com/browse/jsdom@16.2.2/lib/jsdom/living/helpers/focusing.js // https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event plus the steps of
// https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps that adjust Documents to Windows
exports.fireFocusEventWithTargetAdjustment = (name, target, relatedTarget) => {
if (target === null) {
// E.g. firing blur with nothing previously focused.
return;
}
const event = createAnEvent(name, target._globalObject, FocusEvent, {
composed: true,
relatedTarget,
view: target._ownerDocument._defaultView,
detail: 0
});
if (target._defaultView) {
target = idlUtils.implForWrapper(target._defaultView);
}
target._dispatch(event);
}; It's either failing at: view: target._ownerDocument._defaultView, Or: if (target._defaultView) { If you could figure out exactly where and what that |
I'm still looking into it, but it seems that
Then the: target = idlUtils.implForWrapper(target._defaultView); It's then that Which is why |
Thanks for that investigation! I'm starting to think this is a JSDOM bug. What do you think? |
I agree. I don't see anything that's implementation specific to user-event here. I'll make a issue on jsdom outlining my findings and link it here |
👋 I'm the maintainer of Angular Testing Library. import { userEvent } from '@testing-library/angular I think the change detection of Angular is causing issues here. What I did with Angular Testing Library is to patch each invoked event, and it will run the detection cycle after each fired event. This is also the case with |
This is intended for supporting `act` in React, but should be useful for other frameworks (I think it could help with triggering change detection for angular for example). Ref: testing-library/user-event#188, testing-library/user-event#255, https://github.com/testing-library/user-event/issues/277
This is intended for supporting `act` in React, but should be useful for other frameworks (I think it could help with triggering change detection for angular for example). Ref: testing-library/user-event#188, testing-library/user-event#255, https://github.com/testing-library/user-event/issues/277
Now not only will React Testing Library's `fireEvent` be wrapped in `act`, but so will DOM Testing Library's `fireEvent` (if `@testing-library/react` is imported). It works very similar to async act for the `asyncWrapper` config. Closes: testing-library/user-event#188 Closes: testing-library/user-event#255 Reference: https://github.com/testing-library/user-event/issues/277
🎉 This issue has been resolved in version 10.4.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Whoops, I wasn't supposed to close this. However, the latest version should allow |
Thanks @kentcdodds! I was thinking about providing this setup in user-event, but it's better to do so in Dom Testing Library. I will try to add it here later. In the next major version we can then remove the custom user event actions from ATL 🎉. |
🎉 This issue has been resolved in version 9.3.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I have the following test written to test a pagination component:
With one of the buttons being formed like this:
(With the translate pipe coming from
ngx-translate
)However, when I run the tests, I get the following error.
However, if I switch from
user.click
tofireEvent
from@testing-library/angular
, I get no such error and the tests passThe text was updated successfully, but these errors were encountered: