Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda