Increase Timeout for specific its-Method of cypress.io

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

cy.get('ELEMENT', {timeout:50000})

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

Cypress.config('defaultCommandTimeout', 10000);

Cypress.config() documentation


I'd prefer to set timeout for a specific test instead of modifying global config.

it('should do something', {
  defaultCommandTimeout: 10000
}, () => {
  // ...
})

https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Allowed-config-values


Based on Joel's answer, here's what I did to restore to the default timeout right after:

const DEFAULT_COMMAND_TIMEOUT = Cypress.config().defaultCommandTimeout;

// there's no easy way to increase the timeout when using
// `its` command therefore we need to save the current
// timeout, change it globally, and restore it after
Cypress.config('defaultCommandTimeout', 15000);

return cy
  .window()
  .its('something')
  .should('exist')
  .then(() => {
    Cypress.config('defaultCommandTimeout', DEFAULT_COMMAND_TIMEOUT);
  });

Tags:

Cypress