mardi 3 mars 2020

I have an issue to pass a timeout param in get() to should() in my cypress test

cy.get('.buy-order [data-cy=balance]', {timeout: 5000}).then(el => parseFloat(el.text())).should('be.greaterThan', balance);

I have an issue to pass the timeout param in the get() to the should() in the above code. In the then(), I need to extract and modify the data that will be used in should(). In the below line of code, timeout param is passed to the should() correctly. So should() continue to retry its specified assertions until it times out for the custom timeout time. Also, it continues to retry its specified assertion until it is right.

cy.get('.buy-order [data-cy=balance]', {timeout: 5000}).should('be.greaterThan', balance);

But In the below line of code, timeout parm isn't passed to the should(). I think it is caused by the 'then' function in the middle. So should() doesn't continue to retry its specified assertions until it times out for custom the param Also, it deosn't continue to retry its specified assertion until it is right.

cy.get('.buy-order [data-cy=balance]', {timeout: 5000}).then(el => parseFloat(el.text())).should('be.greaterThan', balance);

How can I solve the problem?

Aucun commentaire:

Enregistrer un commentaire