【发布时间】:2022-01-24 13:18:23
【问题描述】:
我有一个问题。 我正在使用 Cypress 进行自动化,我开始使用 async 并等待我的测试。 我正在使用 POM 设计模式。
我的问题: 如果我执行以下测试:
test.spec.ts 类(测试类)
import { login_po } from "../pom/1.Chiquito/login_po";
const pom = new login_po()
describe("Put some name here.", async() => {
it('TestCase1', async () => {
await pom.navigateTo();
});
});
我的 POM 课程。
export class login_po {
navigateTo() {
cy
.visit(`https://chiquito-qa.omnifitrgsites.co.uk/`)
.url()
.should('be.equal', 'https://chiquito-qa.omnifitrgsites.co.uk/').then(() => this.verifyAfterLogin());
}
verifyAfterLogin() {
cy.get('.header__logo-img');
}
}
如果我从测试类中删除 'async' - 'await' - Cypress 会做出 1 个断言。
import { login_po } from "../pom/1.Chiquito/login_po";
const pom = new login_po()
describe("Put some name here.", () => {
it('TestCase1', () => {
pom.navigateTo();
});
});
为什么会这样?
【问题讨论】:
标签: async-await cypress type-assertion