Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any issues using Angular Material with Protractor for E2E testing?

I've been experiencing the intermittent timeouts that are blamed in the Protractor FAQ on use of $timeout for polling (AKA: The waitForAngular timeout). I wonder if it fails also in the cases its not polling. For my team it comes more to light as we rely on the Angular Material components. They are heavy on animation interactions with constant use of $timeout(func, 0). This question is similar to issue #29966301, but focuses on a possible issue between Angular Material and Protractor. I'm really interested to know how folks that heavily utilize Angular Material and Protractor deal with such issues if they encounter them at all.

The interesting point is that I have not seen neither in the Protractor nor Angular Material github sites any utilization of each others capabilities. Since both of them are Angular libraries coming from the same group in Google, @juliemr and the Protractor Gang can talk with @ThomasBurleson and the Material group to come up with comprehensive use cases and E2E tests for Angular Material using Protractor to flush out these issues.

like image 921
Gabriel Kohen Avatar asked Apr 30 '15 11:04

Gabriel Kohen


People also ask

Does Angular still use Protractor?

Angular Team Announces End of Protractor Development By continuing to use Protractor, users may end up with disruptions in their automation scripts. However, the Protractor team has defined a timeline that gives users enough time to look into alternatives and migrate their tests accordingly.

Which E2E test framework would you use in Angular?

End-to-end testing (E2E) of Angular applications is performed using the Protractor testing framework, which is created by the Angular team themselves. Protractor can perform end to end tests on Angular applications that are running in a real browser by interacting with it, similar to that of an end-user.

Why Protractor is getting deprecated?

The Angular team plans to end development of Protractor at the end of 2022 (in conjunction with Angular v15). Why? Protractor was created in 2013 when WebDriver APIs were not yet a standard and end-to-end (e2e) tests were hard to write due to lack of support for async / await .


1 Answers

Well protractor is designed to test angular, so if you are using waitForAngular function and your website is angular you should not use that, you should do the following beforeEach test:

browser.ignoreSynchronization = false; 

and you can do this to make your tests faster and probably help removing the timeout problem, on your protractor-conf.js file add this code:

...

onPrepare: function() {     var disableNgAnimate = function () {         angular.module('disableNgAnimate', []).run(function($animate){             $animate.enabled(false);         });         },     browser.addMockModule('disableNgAnimate', disableNgAnimate); }, 

...

and maybe you should check this video out.

like image 109
Pedro Silva Avatar answered Sep 27 '22 21:09

Pedro Silva