量角器 + 混合 Angular 1+2 应用 = 失败
Protractor + Hybrid Angular 1+2 Application = Fail
量角器在 Angular 1 上运行良好,但在将我的应用程序升级到混合 Angular 1+2 后,我收到此错误:
Failed: Error while waiting for Protractor to sync with the page:
"[ng:test] no injector found for element argument to getTestability
http://errors.angularjs.org/1.4.9/ng/test"
当您的 Angular 1 应用中没有 ng-app 标签 <div ng-app=myAppManager">
时,这似乎是一个常见错误,并且可以很容易地修复 rootElement : 'html'
在你的量角器配置文件中,但它似乎没有改变混合应用程序上的任何内容。
我试过rootElement : 'html'
甚至useAllAngular2AppRoots: true
。
我怀疑问题出在混合 angular 的异步加载(来自 upgrade 文档):
One notable difference between angular.bootstrap and
upgradeAdapter.bootstrap is that the latter works asynchronously. This
means that we cannot assume that the application has been instantiated
immediately after the bootstrap call returns.
我的配置文件:
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());
}
}
Protractor 团队已解决此问题:
https://github.com/angular/angular/pull/7603
编辑:我还没有测试过
编辑 2:好像不行,我又回到了 angularJs(版本 1)
编辑 3:我转向 React
量角器在 Angular 1 上运行良好,但在将我的应用程序升级到混合 Angular 1+2 后,我收到此错误:
Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability http://errors.angularjs.org/1.4.9/ng/test"
当您的 Angular 1 应用中没有 ng-app 标签 <div ng-app=myAppManager">
时,这似乎是一个常见错误,并且可以很容易地修复 rootElement : 'html'
在你的量角器配置文件中,但它似乎没有改变混合应用程序上的任何内容。
我试过rootElement : 'html'
甚至useAllAngular2AppRoots: true
。
我怀疑问题出在混合 angular 的异步加载(来自 upgrade 文档):
One notable difference between angular.bootstrap and upgradeAdapter.bootstrap is that the latter works asynchronously. This means that we cannot assume that the application has been instantiated immediately after the bootstrap call returns.
我的配置文件:
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());
}
}
Protractor 团队已解决此问题:
https://github.com/angular/angular/pull/7603
编辑:我还没有测试过
编辑 2:好像不行,我又回到了 angularJs(版本 1)
编辑 3:我转向 React