【发布时间】:2020-12-31 00:34:59
【问题描述】:
目标是如果停止任何测试的 Cypress 运行器失败,并且这些 Mocha 测试是用 TypeScript 编写的。下面的摩卡afterEach()有两个问题...
/// <reference types="Cypress" />
afterEach(() => {
if (this.currentTest.state === 'failed' &&
this.currentTest._currentRetry === this.currentTest._retries) {
Cypress.runner.stop();
}
});
以下是问题:
-
this.currentTest.*>>> 参考this>>>TS2532: Object is possibly 'undefined' -
Cypress.runner.stop()>>>TS2339: Property 'runner' does not exist on type 'Cypress'
如何在 TypeScript 中解决这个问题并使用 // @ts-ignore 忽略它?
谢谢,感谢您的帮助。
【问题讨论】:
标签: typescript mocha.js cypress