本文介紹了使用量角器檢查瀏覽器控制臺中沒有錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在使用 Protractor 測試 AngularJS
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.
有簡單的方法嗎?
推薦答案
如果你在 Jasmine 中使用 Protractor,請使用以下代碼:
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.
這篇關于使用量角器檢查瀏覽器控制臺中沒有錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!