cypress 包含元素显示顺序

cypress contains element display order

我正在用 cypress 编写 e2e 测试:我想测试 2 个模态弹出窗口的显示:IHM 中的 A 和 B。但由于网络或服务器延迟,A 可能先于 B 显示,或者 B 可能先于 A 显示。 如何用 cypress 编写这种测试?

实际上我卡住了,因为如果我写

cy.get("[data-cy='dialog-confirm-content']").contains(data.notifA, {timeout: 20000});
cy.get("[data-cy='dialog-confirm-content']").contains(data.notifB, {timeout: 20000});

如果B出现在A之前就不行了...

谢谢, 奥利维尔

假设这是流程。显示第一个弹出窗口,然后消失,然后再次弹出第二个弹出窗口,您可以这样做:

cy.get("[data-cy='dialog-confirm-content']").then((text) => {
  expect($ele.text().trim()).to.be.oneOf([data.notifA, data.notifB])
}) //Checks Notification 1 Msg either A or B

cy.get("[data-cy='dialog-confirm-content']").should('not.exist') //Notification goes away

cy.get("[data-cy='dialog-confirm-content']")
  .should('be.visible')
  .then((text) => {
    expect($ele.text().trim()).to.be.oneOf([data.notifA, data.notifB])
  }) //Checks Notification 2 Msg either A or B