4
votes

Since recently, I've been using Protractor for e2e tests for an Angular application.

Lately the e2e tests have stopped working, because Protractor is searching for Angular on the website, but does not find it. I've posted this as an issue, because I also got the problem with their demo app. Turns out the demo application is broken, but this doesn't fix my problem.

The specific outcome when executing ng e2e:

[15:00:22] E/protractor - Could not find Angular on page http://localhost:4200/ : angular never provided resumeBootstrap
  HomePage tests
    ✗ should have a title
      - Failed: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular.
        Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load

With another error following shortly after:

- Failed: Error while waiting for Protractor to sync with the page: 
  "Cannot read property '$$testability' of undefined"

With a fresh demo application using ng new blabla I don't get this error. So it must have something to do with a request on which Protractor is waiting, but never get's resolved.

So my question is: - Did anyone also encounter this problem? - If so, are there steps to check where Protractor gets stuck, so I can fix this? - Or is this a problem in Protractor?

Note: When using browser.ignoreSynchronization = true, Protractor does not sync with Angular and the specs run, but I want to make use of the Protractor features, so this is not desired as a long term solution.

Note: the application is using Angular, not AngularJS

1
check for ng-app directive in login/index.html page. In which tag it is place? - Optimworks
There is no ng-app directive needed in the index.html file because it is an Angular app, not AngularJS. I tried it anyway to see what would happen, but ended up with more errors... - brvh
Okay, before I added ng-app="app" in my body-tag which completely crashed protractor. However, when just adding ng-app in the body-tag seems to have done the trick. I don't understand why and if this is the right way to go, but no more errors for now at least. - brvh
When we run Protractor, it will search for 'ng-app' directive in <body> tag. If it found, Protractor realize that it's Angular app. - Optimworks
Yeah, but for Angular 2, this is not necessary, so it confuses as to why Protractor would search for it... - brvh

1 Answers

2
votes

Okay, I've found two possible ways around this.

The first solution is to add: ... , "typeRoots": [ "../node_modules/@types" ] to your tsconfig.e2e.json file, which solves the problem. This was not included in the generated file from @angular/cli.

The other solution is to add ng-app to the body-tag of the index.html file, though I don't prefer this solution as it looks like more of a hack (mixing AngularJS with Angular) than the other solution.