Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
evitar la devolución de llamada con await cypress no funciona?

Tengo un alias en el resguardo de mi dispositivo, así que esto funciona para mí:

 describe("some page", () => { beforeEach(() => { cy.intercept("/users", { fixture: users.json, }); cy.visit("/somewhere"); }); it("show something", () => { cy.wait("@firstApiCall").then(() => { cy.wait("@2ndApiCall").then(() => { cy.get("test:something").should("exist"); }); }); }); });

pero esto no funcionará?

 it("show something", () => { await cy.wait("@firstApiCall"); await cy.wait("@firstApiCall"); cy.get("test:something").should("exist"); });

Además, ¿cómo puedo evitar repetir cy.wait(apiCall) it cada bloque?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Probablemente falla con:

 Unexpected reserved word 'await'.

y eso se debe a que la palabra clave await solo se puede usar en funciones async , su función de devolución de llamada no es asíncrona.

Podrías escribir:

 it("show something", async () => { await cy.wait("@firstApiCall"); await cy.wait("@firstApiCall"); cy.get("test:something").should("exist"); });

Pero me pregunto por qué quieres hacerlo. Cypress hace un buen trabajo ejecutando los comandos en el orden en que están escritos ( https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#Commands-Run-Serially ).

También dudo que tu ejemplo realmente funcione:

 describe("some page", () => { beforeEach(() => { cy.intercept("/users", { fixture: users.json, }); cy.visit("/somewhere"); }); it("show something", () => { cy.wait("@firstApiCall").then(() => { cy.wait("@2ndApiCall").then(() => { cy.get("test:something").should("exist"); }); }); }); });

No usa alias firstApiCall y 2ndApiCall , por lo que Cypress no sabe qué esperar.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!