Reputation: 16638
The Cypress e2e tests run but I do get an error related to Cypress.Commands.add('loginAs'.
My commands are stored in the folders: cypress/support/commands.ts and seem to be used by my e2e tests. So not sure why I get this error.
I get the following terminal error:
ERROR in cypress/support/commands.ts:1:22 - error TS2345: Argument of type '"loginAs"' is not assignable to parameter of type 'keyof Chainable<any>'.
Tech stack: Angular v15 and Cypress v12.
Example of the command in use:
describe('Check if the app is alive and can login', () => {
beforeEach(() => {
cy.loginAs('Super Admin');
});
it('See welome page and view courses', () => {
cy.get(':nth-child(1) > .card-content > .btn', { timeout: 4000 }).scrollIntoView().click();
cy.url().should('include', '/courses');
});
});
Example of my cypress command add:
Cypress.Commands.add('loginAs', (role?: string) => {
const user = Cypress.env('user');
cy.visit(Cypress.env('local'));
cy.get('#mat-input-0', { timeout: 30000 }).should('be.visible').type(user.email);
cy.get('#mat-input-1', { timeout: 30000 }).should('be.visible').type(user.password);
cy.get('.btn').click({ force: true });
})
Upvotes: 0
Views: 1406
Reputation: 16638
I have actually seen the answer to this question on another stackoverflow question. Here is the link: Argument type string is not assignable to parameter type keyof Chainable... in Cypress
Upvotes: 0