-
Notifications
You must be signed in to change notification settings - Fork 25.3k
-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
RouterTestingModule: DebugElement.triggerEventHandler
errors for an anchor tag
#11804
Comments
Per @vsavkin this is not a bug. It works as intended. We're supposed to pass a mouse This works:
Personally, I'm adding a utility method to my library of helpers (see the docs Testing Chapter)
so now, after importing
|
Talk to Ward about it. This isn't an issue with the router. Closing this issue. |
I don't want to bump, but the docs mentions this usage without describing details of DebugElement. We should fix that for less misperception. |
(Meanwhile) it is mentioned in the docs:
|
I know that this ticket is closed, but I stumbled upon this issue while trying to test click on anchor with no routerLink directive and it won't trigger click event at all. It doesn't display any errors but it won't work either. Is there any indications that this issue will be solved or documentation updated to display the real use case? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
Given a
RouterLink
on an anchor tag like this:The test expression
debugElement.triggerEventHandler('click', null);
throws errorCannot read property 'button' of null
Traced the problem to a line in the generated
component.ngfactory.js
:Notice the reference to
$event.button
. In practice, the$event
is null and wouldn't be a button anyway.See repro
Expected behavior
Should be able to trigger button.
Workaround is to click the native element:
Angular version: 2.0.0-final
Reproduction of the problem
Paste this as a spec in any test harness and watch it fail:
The text was updated successfully, but these errors were encountered: