Danny Danny - 22 days ago 7
AngularJS Question

Globally start a helper function

I want to test for the console errors in my application?

I know how to get them using

browser.manage().logs().get('browser').then(function(browserLog) {})

in afterEach()

What i want to achieve is that i want to use it globally. As in, I don't want to call the helper function in every spec. I want to run it by default when I start the config file and detect if any errors appear in the console.

Answer

As @TehBeardedOne suggested in the comments above, you can do this using the onComplete() function of your config file.

onComplete: function () {
    browser.manage().logs().get('browser').then(function(browserLog) {
        console.log(browserLog);
    });
}

https://github.com/angular/protractor/blob/master/lib/config.ts

Comments