无法在 Cypress.io

问题描述

我在 Cypress.io 中遇到了一个问题,当我加载本地 URL 时,它每次都会出错。我什至在官方文档中提到的 cypress.json 文件添加了 { "baseUrl": "http://localhost:4200" } 。

以下是我的几个测试脚本:

it('successfully loads',() => {
  cy.visit('http://localhost:4200/') // change URL to match your dev URL
})
it('successfully load',() => {
    cy.visit('/') // change URL to match your dev URL
})

enter image description here

解决方法

我不确定为什么会在这种情况下发生错误,但是如果您只需要将其关闭 - 您可以在 cy.visit 调用下添加此行。错误不应再次发生。

Cypress.on('uncaught:exception',(err,runnable) => { return false; })