概述
在開發或測試環境中前端在 console 中可能會有 exception 出現,但這就會造成 Cypress 執行測試時產生以下錯誤
index-bf83b30a.js:133765 Error: The following error originated from your application code, not from Cypress.
> undefined
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.
解決
如果想要暫時忽略這個錯誤以便繼續測試,可以在測試的程式中加入這段程式碼
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})