Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
Calling Cypress tests from another Cypress test file

I am writing some Cypress test to test an account deletion feature. Since the test is going to be deleting an account every time it runs I first want to create an account. I already have a test file for creating an account.

describe("Create Email User", () => {
    beforeEach(() => {
        cy.restoreLocalStorage();
    });

    afterEach(() => {
        cy.saveLocalStorage();
    });

    it("Clicks to Create New User", () => {
        cy.visit("/signin");
        cy.get('[data-cy="login-main-sign-up-link"]').click();
        cy.get('[data-cy="sign-in-content-top-header-text"]').should(
            "contain",
            "Create your account"
        );
    });

    it("Enters Form Data", () => {
        cy.get('[data-cy="sign-up-name-first-name-input"]').type("John");
        cy.get('[data-cy="sign-up-name-last-name-input"]').type("Smith");
        const newEmail = createEmail();
        cy.get('[data-cy="sign-up-name-email-input"]').type(newEmail);
        cy.get('[data-cy="sign-up-name-password-input"]').type("test123!");
        cy.get('[data-cy="sign-up-name-next-button"]').click();
        cy.get('[data-cy="sign-up-phone-header-text"]').should(
            "contain",
            "What's your phone number?"
        );
    });

    it("Reloads the page and clicks next button", () => {
        cy.reload();
        cy.get('[data-cy="sign-up-onboarding-intro-header-text"]').should(
            "contain",
            "Great! Let's set up your account"
        );
        cy.get('[data-cy="sign-up-onboarding-next-button"]').click();
        cy.get('[data-cy="sign-up-role-wizard-header-text"]').should(
            "contain",
            "What role best describes you?"
        );
    });

    it("Selects Family/Friend role and clicks next button", () => {
        cy.get('[data-cy="sign-up-role-wizard-Family/Friend"]').click();
        cy.get('[data-cy="sign-up-role-wizard-next-buton"]').click();
        cy.get('[data-cy="sign-up-base-header-text"]').should(
            "contain",
            "Do you know which base your trainee is going to?"
        );
    });

    it("Selects No button and clicks next button", () => {
        cy.get('[data-cy="sign-up-base-no-button"]').click();
        cy.get('[data-cy="sign-up-base-next-button"]').click();
    });
});

Now I am working on the account delete tests. I want to first call the create account tests so that I am sure there is an account to delete.

How do I call a testing file to run from another test file?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try using custom commands in cypress so that the login functionality can be used in other tests also

Refer https://docs.cypress.io/api/cypress-api/custom-commands#Syntax

about 4 years ago · Juan Pablo Isaza Relatório

0

It looks like a process for test setup and clean ups and highly depends on what you are wanting to achieve.

You definitely want to either:

  • move this into a custom Cypress command in the support/commands.js
  • create a utility function that can be called inside before() or beforeEach() and place them where it fits the project best
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda