I am writing end to end test cases for my angular application. I need to check for dates that are in correct format. So I want to inject the 'datefilter', so that I can use it in protractor.
When i 'googled' i found that i can use the browser.executeAsyncScript to get the injector and then use
angular.injector(["ng"]).get("dateFilter");
to get the datefilter.
But i am still not able to put them all together in code. Any heads-up would be enough to get me going with the code.
Theoretically you can access your services like this:
browser.executeAsyncScript(function(callback) {
var service = angular.injector(['MyModule']).get('myService');
service.query({}, function(data) {
callback(data);
});
}).then(function (output) {
console.log(output);
});
And there is an example:
https://github.com/andresdominguez/protractor-meetup/blob/master/test/e2e/api-helper.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With