我正在编写 Cypress 测试并在终端中无头运行它们。即使测试应该失败,但它们仍然通过了。
例如编写这段代码:
describe('Website Landing', () => {
it.only('Should load', async () => {
cy.visit('http://www.mywebsite.com/');
cy.get('[data-testid="sign-inx"]');
})
})
在终端上运行此命令将成功结束:
cypress run
但是不存在具有这样的属性和值的元素。如果我在最后添加其他断言,测试就会继续通过
cy.get('[data-testid="sign-inx"]').should('have.length', 1);
我不明白赛普拉斯如何设法允许测试通过和失败。有人可以帮忙吗?
Cypress 版本是 13.15.1