How to use Protractor with Angular 2?
You can test Angular 2 applications with Protractor
(starting from Protractor 2.5.0).
For Protractor 5.0.0+, you don't have to do anything specific, Protractor will auto-detect the Angular version used in the application under test.
For Protractor >= 2.5.0 and <= 4.0.14, you would only need to add useAllAngular2AppRoots: true
to your config. Here is a sample.
Note that several built-in Protractor matchers would not yet work with Angular2, see:
There is also that Protractor+Angular2 problem in Firefox (still unresolved), see:
Related videos on Youtube
JohnnyC
Updated on July 09, 2022Comments
-
JohnnyC almost 2 years
I use Protractor with Angular 1.x. I would like to migrate to Angular 2.0 step by step but I don't see Protractor in the docs.
Has protractor been dropped since Angular 2? Should I write my tests without using Protractor, using Jasmine instead (or others)?
-
Eric Martinez over 8 yearsNot at all, if you see in the playground e2e examples most of them, if not all, use protractor.
-
jornare over 8 yearsTo me, that qualifies as an answer @EricMartinez
-
JohnnyC over 8 yearsYes, it's a response part but it's TS and not JS pure and this files aren't an official status on Protractor's futur. But thank you, this is an initial response
-
-
rarrarrarrr about 8 yearsHow does it work to test a website that is mixed angular 1.x and angular 2? Is that a use-case that just isn't supported?
-
michael_hook almost 8 yearsWhile you can use Protractor with Angular 2 at this time there are several key matchers which don't work, as explained on this post: stackoverflow.com/questions/36201691/…
-
Eric Francis about 7 yearsgithub.com/angular/protractor/blob/master/CHANGELOG.md#500 This was changed in Protractor 5.0.0
-
alecxe about 7 years@EricFrancis thanks for the update! I've updated the answer, let me know if you think we can add anything else here.