https://cypress.io logo
Cypress custom commands type script help
# i-need-help
r
Hey All. I created this custom command for google recapture in the
commands.ts
file Cypress.Commands.add('confirmReCAPTCHA', () => { // Wait until the iframe (Google reCAPTCHA) is totally loaded return cy.get('iframe') .first() .its('0.contentDocument.body') .should('not.be.undefined') .and('not.be.empty') .then(cy.wrap) .find('#recaptcha-anchor') .should('be.visible') }); I get the following error "Argument of type '"confirmReCAPTCHA"' is not assignable to parameter of type 'keyof Chainable'.ts(2345)" , whats wrong am I doing here ? This was working fine with JavaScript , issue seems to be with TypeScript now that we switched. I cannot call the command in my cy.ts spec
e
Have you added your custom command to the global Cypress Chainable interface? https://docs.cypress.io/guides/tooling/typescript-support#Types-for-Custom-Commands
b
ypu should create an interface with your custom commands
r
thank you @enough-truck-68085 and @bland-oil-21931 the above solution resolved my issue.