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

266
Visualizações
running cypress test cases with assertion expect(xhr.requestBody.test).to.not.exist, but eslint throws error
 cy.wait("api").then((xhr: any) => {
      expect(xhr.method).to.eq("POST");
      expect(xhr.status).to.eq(200);
      expect(xhr.requestBody.test).to.not.exist;
    });

expect(xhr.requestBody.test).to.not.exist; this line throws eslint error as shown below:

error  Expected an assignment or function call and instead saw an expression  @typescript-eslint/no-unused-expressions
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

In my opinion you have multiple options to solve this:

First and recommended option is to rewrite your assertion for example as follows:

const bodyContainsTest = xhr.requestBody.hasOwnProperty('test');
expect(bodyContainsTest).to.be.false;

Second option would be to simply disable that rule for the next line:

// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(xhr.requestBody.test).to.not.exist;

Another option would be to disable this rule globally for all Cypress test files in your .eslintrc.json if needed:

"@typescript-eslint/no-unused-expressions": "off",
about 4 years ago · Juan Pablo Isaza Relatório

0

Verified at tslint-playground.

Two alternates that pass the linter:

expect(xhr.requestBody).to.not.have.property(test)

expect(xhr.requestBody.test).to.eq(undefined)
about 4 years ago · Juan Pablo Isaza 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