So I'm trying to add a custom command in cypress (commands.js file) like so:
Cypress.Commands.add("login", (email, password) => {
cy.intercept('POST', '**/auth').as('login');
cy.visit('/auth');
cy.get('[formcontrolname="email"]').type(email);
cy.get('[formcontrolname="password"]').type(password);
cy.get('form').submit();
cy.wait('@login').then(xhr => {
expect(xhr.request.body.email).to.equal(email);
expect(xhr.request.body.password).to.equal(password);
});
});
but I get this error:
'Argument type string is not assignable to parameter type keyof Chainable ... Type string is not assignable to type "and" | "as" | "selectFile" | "blur" | "check" | "children" | "clear" | "clearCookie" | "clearCookies" | "clearLocalStorage" | "click" | ... Type string is not assignable to type "intercept"'
I've found this question Argument type string is not assignable to parameter type keyof Chainable... in Cypress, but the answers here are only applicable for an index.d.ts file, however I have an index.js file (cypress version 10.3.0 and this is not working for me. Can anyone help me solve this issue?