I am aware that binding to jquery events in angular "controller" is not in line with this framework philosophy but it allows me to migrate views in asp.net mvc project to angular step by step. This works on runtime but i can't test this. If I have binded jquery event 'keydown' on input field in "controller" and I try to trigger() this event in my test scenario (I am using angular-scenario.js) this event simply is not recieved in "controller". I cant use input().enter() as this input is not part of model (as I said on beginning...). Question: is it possible to trigger event from scenario? If not, should I use different test runner?
Asked
Active
Viewed 1,535 times
2 Answers
2
the link above is point to a angular UT rather than e2e case, you may trigger a dom event in e2e via its query api, for example
element('#something_id').query(function(el, done){
var evt = document.createEvent('Event');
evt.initEvent('focus', false, true);
el[0].dispatchEvent(evt);
done();
});

Roger Jin
- 553
- 5
- 15
-
This really helped for a problem i was having with e2e tests. Specifically retrieving values from dynamically created input fields - It seems strange that this is the only way to test this scenario http://plnkr.co/edit/ahuT3hL92az0aQBHxRVl – shane Aug 26 '13 at 10:28
0
You can take a look into AngularJS tests. They use browserTrigger(element, 'keydown');
to trigger DOM events on elements.
Here is example from AngularJS source

Valentyn Shybanov
- 19,331
- 7
- 66
- 59