Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase Timeout for specific its-Method of cypress.io

Tags:

cypress

With cypress.io get-Method we can define a timeout only valid for this specific get-method call:

cy.get('.mobile-nav', { timeout: 10000 })

Is there a way to define a timeout for a specific its-method call like:

cy.window().its('MyClass')

Or do I need to increase defaultCommandTimeout in cypress.json?

like image 299
toasty Avatar asked Mar 06 '19 08:03

toasty


People also ask

How do you increase Cypress timeout?

Else, we can provide a default timeout by adding "defaultCommandTimeout": 10000 in cypress. json which will by default add a 10-second timeout for all the commands.

How does Cypress handle timeout?

Use the Cypress intercept and aliasing commands to require Cypress to wait on your asynchronous operations to complete before running the next command or assertion. Use the Cypress intercept command to control all the network traffic necessary to your tests to eliminate inconsistencies across test runs.

How do you wait for a particular element in Cypress?

Use timeout per command Sometimes, you simply want to wait until a certain element appears, but everything else on the page is pretty fast. For these cases, you can use the options object and change timeout for a certain command. Notice how we are adding the timeout into our . get() command, not the .


2 Answers

For me, I just do this wherever I wanted to wait

cy.get('ELEMENT', {timeout:50000})
like image 190
Maria Avatar answered Oct 23 '22 17:10

Maria


Place this in the its block before you want it used:

Cypress.config('defaultCommandTimeout', 10000);

Cypress.config() documentation

like image 24
Joel Avatar answered Oct 23 '22 19:10

Joel