Marek Javůrek
Marek Javůrek

Reputation: 965

Assertion fails but test is successful

This is crucial think in cypress.io and does not work (Assertion fails but test is successful). Full code below. I have tried to rewrite my code many times, without success. Installed latest NPM, latest Node.JS. Deleted node_modules and reinstalled dependencies.

enter image description here

/* 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");
  });
});

Upvotes: 0

Views: 228

Answers (2)

Sarah G
Sarah G

Reputation: 31

As far as I know, you cannot automate captcha

Upvotes: 0

bestOri
bestOri

Reputation: 11

Known issue?

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

Are you running the latest cypress (3.1.5)?

Upvotes: 1

Related Questions