Javascript 将量角器配置为忽略浏览器控制台错误

Javascript 将量角器配置为忽略浏览器控制台错误,javascript,angularjs,testing,protractor,Javascript,Angularjs,Testing,Protractor,我试图为web应用程序编写测试,但有一些困难。 当我使用web应用程序时,浏览器控制台中出现了一些角度错误。这不是致命错误,它们不会干扰应用程序的执行 但当我运行量角器测试时,它在第一个浏览器控制台错误时失败 是否有方法将量角器测试配置为执行测试场景并检查场景以获得结果,而忽略这些浏览器控制台错误 我的测试文件: var testingAdress = 'http://localhost:1340', describe('admin avtorization test', functi

我试图为web应用程序编写测试,但有一些困难。 当我使用web应用程序时,浏览器控制台中出现了一些角度错误。这不是致命错误,它们不会干扰应用程序的执行

但当我运行量角器测试时,它在第一个浏览器控制台错误时失败

是否有方法将量角器测试配置为执行测试场景并检查场景以获得结果,而忽略这些浏览器控制台错误

我的测试文件:

var
    testingAdress = 'http://localhost:1340',

describe('admin avtorization test', function(){
    beforeEach(function(){
        // should be called before each it block
    });

    it('should avtorizate as admin', function(){

        browser.get(testingAdress);

        expect(browser.getCurrentUrl()).toEqual('localhost:1340'+'/#!/');

        //element(by.linkText('Sign Up')).click();

        //expect(browser.getCurrentUrl()).toEqual(testingAdress + '/#!/signup');

        //element(by.id('myLink').click());
        //expect(browser.getCurrentUrl()).toEqual("http://myUrl.com");
    });

});
我的配置文件:

exports.config = {
    directConnect: true,

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        //'browserName': 'firefox'
        'browserName': 'chrome'

    },

    // Framework to use. Jasmine is recommended.
    framework: 'jasmine',

    // Spec patterns are relative to the current working directory when
    // protractor is called.
    specs: ['spec/avtorization_test.js'],

    // Options to be passed to Jasmine.
    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    },

    plugins: [{
        package: 'protractor-console-plugin',
        failOnWarning: false,
        failOnError: false,
        logWarnings: false
    }]
};
以下是我在浏览器控制台中的错误

unreachable code after return statement application.js:27995:8
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D
 application.js:71011:12
"Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D
minErr/<@http://localhost:1340/js/application.js:71011:12
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:1340/js/application.js:87720:1
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:1340/js/application.js:87946:13
bootstrapApply@http://localhost:1340/js/application.js:72656:9
invoke@http://localhost:1340/js/application.js:75568:16
bootstrap/doBootstrap@http://localhost:1340/js/application.js:72654:1
bootstrap@http://localhost:1340/js/application.js:72674:1
[29]</</<@http://localhost:1340/js/application.js:120390:3
trigger@http://localhost:1340/js/application.js:74070:7
defaultHandlerWrapper@http://localhost:1340/js/application.js:74360:3
createEventHandler/eventHandler@http://localhost:1340/js/application.js:74348:9
" application.js:84237:18

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D
 application.js:71011:12
"Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D
minErr/<@http://localhost:1340/js/application.js:71011:12
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:1340/js/application.js:87720:1
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:1340/js/application.js:87946:13
done@http://localhost:1340/js/application.js:82267:36
completeRequest@http://localhost:1340/js/application.js:82465:7
requestLoaded@http://localhost:1340/js/application.js:82406:1
"
返回语句应用程序后无法访问的代码。js:27995:8 错误:[$rootScope:infdig]已达到10$digest()次迭代。流产! 在过去5次迭代中激发的观察者:[] http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D application.js:71011:12 “错误:[$rootScope:infdig]已达到10$digest()次迭代。正在中止! 在过去5次迭代中激发的观察者:[] http://errors.angularjs.org/1.5.2/$rootScope/infdig?p0=10&p1=%5B%5D
Miner/这不是默认的量角器行为

听起来您正在使用
failOnWarning
设置为true,请修复它:

plugins: [{
  package: 'protractor-console-plugin',
  failOnWarning: false,
  failOnError: true,
  logWarnings: true
}]

感谢您的回答,但这不是测试失败的原因。我在测试之前没有安装该插件。现在我尝试安装该插件,并将其配置为:插件:[{程序包:“量角器控制台插件”,failOnWarning:false,failOnError:false,logWarnings:false}]这对我没有帮助。Protracktor测试在控制台错误后失败。还有一些其他机制,在控制台错误后测试失败。你知道此任务的其他配置功能吗。@pj infest很有趣!你能提供更多详细信息吗:你的量角器配置和你正在执行的测试?谢谢。@pj infest你能告诉我吗请尝试将量角器升级到最新版本,并使用
jasmine2
而不是jasmine-它有帮助吗?谢谢。jasmine2 npm包装的名称是什么?@pj感染了我的坏习惯,只需将其保留
jasmine
-最新量角器将自动使用最新的jasmine-jasmine2。
plugins: [{
  package: 'protractor-console-plugin',
  failOnWarning: false,
  failOnError: true,
  logWarnings: true
}]