当我在本地运行测试时,它们工作得很好。我已经推送到我的管道,但现在它不起作用并且出现此错误。
这是我在管道中遇到的错误
类型错误:cy.login 不是函数
由于此错误发生在挂钩期间,我们将跳过当前套件中的剩余测试before each
它看起来像一个 Typescript 错误,尽管您使用的是
.js
扩展而不是 .ts
。如果 Gitlab 正在应用类型检查,请尝试定义 cy.login()
自定义命令的类型。
这里是文档自定义命令的类型
// cypress/support/index.ts
declare global {
namespace Cypress {
interface Chainable {
login(username: string, password: string): Chainable<any>
}
}
}