Trying to incorporate a unique custom command in Cypress (commands.js file) as follows:
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);
});
});
An error is encountered with the message:
'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"'
A relevant question can be found here Argument type string is not assignable to parameter type keyof Chainable... in Cypress, however, the solutions presented apply solely to an index.d.ts file, whereas I am working with an index.js file for cypress version 10.3.0. Any assistance on resolving this issue would be greatly appreciated.