如何定义Cypress任务返回类型的类型



我的目标是为用typescript编写的cyprus任务定义类型。

我目前在使用自定义任务时有这个:

cy.task('customTask').then(v => {
// v is undefined here - how can I configure types?
});

插件/索引.ts

module.exports = (on) => {
on('task', {
customTask: () => {
return 23;
}
});
}
/// <reference types="cypress" />
declare global {
namespace Cypress {
interface Chainable {
task(event: 'customTask'): Chainable<number>;
}
}
}

最新更新