【问题标题】:Assertion fails but test is successful断言失败但测试成功
【发布时间】:2019-03-05 09:39:47
【问题描述】:

这是 cypress.io 中的关键思想并且不起作用(断言失败但测试成功)。完整代码如下。我曾多次尝试重写我的代码,但均未成功。安装了最新的 NPM,最新的 Node.JS。删除 node_modules 并重新安装依赖项。

/* eslint-disable no-undef */
describe("Contact us form", () => {

  beforeEach(() => {
    cy.visit("/");

    cy.contains("Contact us").click();

    cy.location().should(loc => {
      expect(loc.pathname).to.eq("/contact-us");
    });
  });

  it.only("Fill Contact us form - error 500", () => {
    cy.server();

    cy.route({
      method: "POST",
      url: "/api/v1/email/contact-us",
      status: 500,
      response: {}
    }).as("sendMessage");

    cy.getTestElement("ContactUs__form__container").within(() => {
      cy.get("@users").then(users => {
        const user = users.admin;

        cy.get("#name")
          .type(user.name)
          .should("have.value", user.name);

        cy.get("#email")
          .type(user.email)
          .should("have.value", user.email);

        cy.get("#phone")
          .type(user.phone)
          .should("have.value", user.phone);

        const message = Cypress.config("testVars").testMessage;

        cy.get("#message")
          .type(message)
          .should("have.value", message);
      });

      cy.get("button:first").click(); // "Send message"
    });

    cy.wait("@sendMessage");

    cy.get("#alert-dialog-description").contains("My App");
  });
});

【问题讨论】:

    标签: reactjs testing automated-tests cypress


    【解决方案1】:

    已知问题?

    https://github.com/cypress-io/cypress/issues/3497

    你运行的是最新的 cypress (3.1.5) 吗?

    【讨论】:

    • 是的:“柏树”:“^3.1.5”。似乎是这个问题(已经评论)。我正在寻找一些修复。看起来很奇怪,很厉害,而且 18 天没有修复...
    • 让我们关注 Github 上的 issue。看起来确实是一个表演者。
    【解决方案2】:

    据我所知,您无法自动化验证码

    【讨论】:

      猜你喜欢
      • 2011-10-13
      • 1970-01-01
      • 2015-06-24
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 2017-04-10
      • 2020-10-08
      • 1970-01-01
      相关资源
      最近更新 更多