Testability is an important discipline in application development. Angular was always built with testability in mind. Protractor is Angular’s end-to-end testing framework. It was originally created for AngularJS, the first edition of the popular SPA framework, but works perfectly with Angular 2 by simply setting useAllAngular2AppRoots
to true
in Protractor’s config.js. In addition, you can optionally specify an element name for the rootElement
property to exclusively test against this element.
exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'], useAllAngular2AppRoots: true, // rootElement: 'root-element' };
However, if you are using Angular 2 and Protractor in combination, you might stumble upon one of the following error messages:
Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md.
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Here’s how to fix those errors:
Continue reading Angular 2 & Protractor Timeout: Here’s How to Fix It