Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  161] [ 2]  / answers: 1 / hits: 6444  / 10 Years ago, tue, june 3, 2014, 12:00:00

I'm using Protractor to test AngularJS



I want to check that at the end of the test no uncaught exceptions occurred and were printed to the browser console.



Is there a simple way to do that?


More From » angularjs

 Answers
8

If you're using Protractor with Jasmine, use the following code:



afterEach(function() {
browser.manage().logs().get('browser').then(function(browserLog) {
expect(browserLog.length).toEqual(0);
});
});


This will pass the test case if there are no console errors. If there are any console errors, the test will fail.



Instructions on how to access the content of the browser's console can be found in the How can I get hold of the browser's console section of the FAQ.


[#44854] Monday, June 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;