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

126
Views
Using async await inside a .then() statement in cypress

In the cypress test I am writing I need to first get a value from an attribute of an element and then with that attribute value I can then make a query to the database and compare values on the page with those in the database.

To do this I have tried to use a .then() with asynchronous code inside and await the database query. However, cypress keeps generating the following error:

cy.then() timed out after waiting 15000ms.Your callback function returned a promise that never resolved.

Below is the code I am trying to use:

  checkForAndSelectNextDropdown(indexArray: Array<number>): void {
    for (const index in indexArray) {
      this.loadingUnitIcon.should('not.exist');
      cy.get('.symbolic-button').eq(parseInt(index)).click();
      cy.get('.task.open').eq(parseInt(index)).then(async (el) => {
        const parentTaskOrgID = el.attr('data-testid').split('-')[1];
        const queryResult = await GraphqlService.runQuery('siblingSequence.graphql', { parentTaskOrgID });
        const { workforce, vehicles } = queryResult;
        cy.contains(`Vehicles (${vehicles}) Workforce (${workforce})`).should('be.visible');
      })
    }
  }

If anyone can spot issues with my code or knows a way around this issue then please let me know

about 4 years ago · Juan Pablo Isaza
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!