Cypress · Middle · Question 19 of 77

How do you add TypeScript types for a custom command cy.login?

Show the answer

Correct answer: Declare it in the Cypress.Chainable interface

Explanation

Extending namespace Cypress { interface Chainable { login(...): Chainable<void> } } gives autocompletion and type checks.

Further reading

Problem with a question

Cypress · Middle · question 19

Test yourself

Take the Cypress · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz