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

304
Views
Mocha pasa la prueba cuando espero lanzar, pero mi función no es lanzar

Tengo una función que espero que arroje un error, pero si no lo arroja, Mocha pasa la prueba.

 async function throwError() { throw new Error("foo"); } async function notThrowError() { }

Prueba:

 describe("bar", function(){ it("bar-2", async function() { await expect(throwError()).throw //passes the test }) } describe("bar", function(){ it("bar-2", async function() { await expect(notThrowError()).throw //passes the test, but no error has been thrown }) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería usar chai as promised

 const chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); chai.should(); describe("bar", function(){ it("bar-2", async function() { return notThrowError().should.eventually.rejected; //do not pass the test if not throw an error }) }
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!