Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

617
Visualizações
Argument type string is not assignable to parameter type keyof Chainable ... cypress JS

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?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

You shouldn't mix .js and .ts in a Typescript project.

Make everything .ts, then add the index.d.ts with a type definition for your custom command.

/// <reference types="cypress" />

declare namespace Cypress {
  interface Chainable<Subject = any> {
    login(): Chainable<any>;
  }
}

You may run into more problems, for example check if you have a tsconfig.json in the /cypress folder.

If in doubt, use cypress-realworld-app as a reference for Typescript setup.

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda