Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!