Search code examples
javascripttypescriptcypress

Why is defaultCommandTimeout not working in my script


I know there is this solution of adding defaultCommandTimeout in the cypress.json file, but I do not want to add wait everywhere in my entire test framework.

I only need to only wait for one particular element.

    add.getCountry().type('India');
    Cypress.config('defaultCommandTimeout', 10000);
    add.selectCountry().click();

Cypress result:

cypress result


Solution

  • You can add timeouts to individual cypress commands, something like:

    cy.get('.suggestions > ul > li > a', { timeout: 10000 }).should('be.visible')