赛普拉斯测试执行期间如何捕获意外错误消息? [英] How can I catch unexpected error messages during Cypress test execution?
本文介绍了赛普拉斯测试执行期间如何捕获意外错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Cypress和iziToast(
失败了,我能否获得对click()命令的网络响应?
解决方案
下面的代码。此代码段将帮助您在cypress测试流程中捕获异常。
Cypress.on('uncaught:exception',( err,runnable)=> {
console.log( err: + err)
console.log( runnable: + runnable)
返回false
})
I am using Cypress and iziToast (http://izitoast.marcelodolce.com/) to run some tests on a web application. I spotted an unexpected error message whilst running it locally. I was able to catch it by adding the following cy.toast statement to my code:
cy.get(tabbedPanelControlsTitle)
.should('have.value', 'Teams')
.click();
// this is causing the following unexpected error
cy.toast({
type: 'Error',
code: 'E1527360562',
});
I was able to get it to fail here using the following:
cy.wrap({ toast: 'Error' })
.its('toast')
.should('eq', 'Success');
What I would like to know is there any way of catching these unexpected errors?
Toast Message:
Failing that, can I get the Network response to my click() command?
解决方案
You can try the below code. This snippet will help you to catch the exception in the cypress test flow.
Cypress.on('uncaught:exception', (err, runnable) => {
console.log("err :" + err)
console.log("runnable :" + runnable)
return false
})
这篇关于赛普拉斯测试执行期间如何捕获意外错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文