45

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)?

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
JohnnyC
  • 1,425
  • 1
  • 21
  • 38
  • 7
    Not at all, if you see in the [playground e2e examples](https://github.com/angular/angular/tree/master/modules/playground/e2e_test) most of them, if not all, use protractor. – Eric Martinez Nov 05 '15 at 14:31
  • To me, that qualifies as an answer @EricMartinez – jornare Dec 02 '15 at 08:55
  • 2
    Yes, 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 – JohnnyC Dec 02 '15 at 14:18

1 Answers1

42

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • 3
    How 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? – rarrarrarrr Apr 28 '16 at 14:04
  • 1
    While you can use Protractor with Angular 2 at this time there are several key matchers which don't work, as explained on this post: http://stackoverflow.com/questions/36201691/protractor-angular-2-failed-unknown-error-angular-is-not-defined – michael_hook Jun 28 '16 at 08:38
  • https://github.com/angular/protractor/blob/master/CHANGELOG.md#500 This was changed in Protractor 5.0.0 – Eric Francis Feb 16 '17 at 23:43
  • 1
    @EricFrancis thanks for the update! I've updated the answer, let me know if you think we can add anything else here. – alecxe Feb 17 '17 at 02:49