Protractor + Hybrid Angular 1 + 2 Application = Failure

The protractor works well on Angular 1, but after upgrading my application to hybrid Angular 1 + 2, I get this error:

Error: Error while waiting for Protractor to synchronize with the page: "[ng: test] no injector was found for element argument to getTestability http://errors.angularjs.org/1.4.9/ng/test "

This seems like a common mistake when you do not have the ng-app tag <div ng-app=myAppManager">in your Angular 1 application and can be easily fixed by wiyh rootElement : 'html'in your protractor configuration file, but it does not seem to change anything in the hybrid application.

I tried rootElement : 'html'or even useAllAngular2AppRoots: true.

I suspect the problem is with asynchronous loading of hybrid Angular (from upgrade doc):

One noticeable difference between angular.bootstrap and upgradeAdapter.bootstrap is that the latter works asynchronously. This means that we cannot assume that the application was created immediately after the bootstrap call returned.

my configuration file:

exports.config = {
    framework: 'jasmine2',
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['protractor.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 50000,
    },
    allScriptsTimeout: 50000,//seb
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
            'prefs': {
                'profile.managed_default_content_settings.notifications':2
            }
        }
    },
    rootElement : 'html',
    // useAllAngular2AppRoots: true,
    jasmineNodeOpts: {
        realtimeFailure: true
    },
    onPrepare: function() {
      var failFast = require('jasmine-fail-fast');
      jasmine.getEnv().addReporter(failFast.init());
    }
}
+5
source share
1 answer

The protractor team fixed this:

https://github.com/angular/angular/pull/7603

Change: I have not tested yet

Edit 2: doesn't seem to work, I returned to angularJs (version 1)

Edit 3: I switched to React

+1
source

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


All Articles