Using protractor with ng update

I am working on porting an AngularJS (1.6) application to Angular (4) and now I have a hybrid application downloaded using NgUpgrade.

However, this seems to have completely broken my Protractor tests.

Crash: Timeout to complete Angular asynchronous tasks after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more information: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular

Waiting for an element with a locator - Locator: By (css selector, .toggle-summary-button)

Hybrid Changes

The application is working fine, and the AngularJS and Angular components are working properly. The changes I made during the boot process are as follows:

1 Removed ng-appfrom html tag:

<html lang="en" *ng-app="myapp">

2 Added AppModules (@NgModule), etc.

3 Used by NgUpgrade to download the application:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { UpgradeModule } from '@angular/upgrade/static';
import { AppModule } from './app.module';

platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
  const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
  upgrade.bootstrap(document.body, ['myapp'], {strictDi: true});
});

Catcher Tests

Based on the above error, the problem seems to be related to what Protractor does when it waits for Angular. I have a beforeEach block that loads the login page, fills in the details and logs in. It is unlikely that he still opens the page and enters text in the username field, but then he can’t move on.

I can’t understand why this is no different, and no amount of changes around helps, so any guide would be very welcome!

I tried, without success:

  • "rootElement: 'body"
  • "ng12Hybrid: true" . , , .
  • allScriptsTimeout 11000 60000, .
  • waitForAngularEnabled. , HTTP- .
+4
1

, (+github) 15 angular 1 2:

+ angular 1 + 2 =

- angular 1. angular 1 4, , , ...

, ... , . , AngularJ - Angular 2+! ( , , )...

: ,

+6

Source: https://habr.com/ru/post/1677270/


All Articles