johnnyevolunium johnnyevolunium - 1 month ago 37
Javascript Question

How to use Protractor with Angular 2?

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

Answer

You can test Angular 2 applications with Protractor starting from 2.5.0.

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:


If you are curious what changed in Protractor to support Angular 2, here you are:

When useAllAngular2AppRoots is set to true, it now uses GetTestability interface to get Testability objects for all Angular 2 apps under test and then waits for them to become stable (changelog1, changelog2).