TS - 属性"then"在类型"Allure"上不存在



当尝试使用https://github.com/Shelex/cypress-allure-plugin在Cypress测试中标记步骤时,我有以下代码:

cy.allure().startStep('Step 1').then(() => {
cy.visit('/path1/path2');
});
cy.allure().endStep();

但是,.then(() => {})正在引起TS错误:

[ts] type 'Allure'中不存在属性'then'。

我tsconfig。(我尝试将/reporter附加到cypress-allu -plugin行,如https://github.com/Shelex/cypress-allure-plugin-example/blob/master/cypress/tsconfig.json所示,但没有工作):

{
"compilerOptions": {
"baseUrl": "..",
"target": "es5",
"lib": [
"es5",
"es2016",
"dom"
],
"types": [
"cypress",
"@testing-library/cypress",
"@shelex/cypress-allure-plugin"
],
},
"include": [
"**/*.ts"
]
}

.then()是隐含的,因为Cypress运行在命令队列上。

按这样的顺序排列命令

cy.allure().startStep('Step 1')
cy.visit('/path1/path2');
cy.allure().endStep();

参见repo

中的示例
describe('Cypress commands steps', () => {
it('should produce allure steps for cypress chainer commands', () => {
cy.log('before command');
cy.allure().startStep('step before "this is custom"');
cy.thisiscustom('customname').then(() => {
cy.allure().testName('new name');
});
cy.allure().endStep();
cy.allure()
.startStep('step nested 1')
.startStep('step nested 2')
.startStep('step nested 3');
cy.request('https://google.com.ua')
.should('have.property', 'status')
.should('be.eq', 200)
.and('be.not.eq', 400);
cy.allure().endStep().endStep();
cy.wrap([1, 2, 3])
.then((array) => array[0])
.as('firstItem')
.should('be.eq', 1);
cy.allure().endStep();
cy.allure().step('step parent 1');
cy.get('@firstItem').then((item) => {
cy.log(item);
});
cy.allure().step('step parent 2');
cy.request('https://google.com').then((res) => {
cy.log(res);
});
cy.log('after command');
});
})

最新更新