Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda