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