【发布时间】:2022-01-20 18:21:08
【问题描述】:
我已经为我的赛普拉斯测试设置了自定义命令:
// cypress/support/commands.ts
/// <reference types="cypress"/>
Cypress.Commands.add('getByTestId', (target: [string], timeout: number = 0) => {
target[0] = `[data-testid="${target[0]}"]`;
return cy.get(target.join('>'), { timeout });
});
// cypress/support/index.ts
/// <reference types="cypress" />
declare global {
namespace Cypress {
interface Chainable {
getByTestId(id: string): Chainable<Element>;
}
}
}
这些是我设置命令的文件。
在编写测试时,即使我的文件顶部有这个错误 /// <reference types="cypress" /> :
cypress/integration/filename.test.e2e.ts
【问题讨论】:
标签: typescript cypress e2e-testing