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

151
Views
How to use Nock with mocha

I am using nock with mocha for restapi testing. but when i used .reply(200,"msg" :"url matched").they only check 200 response in server coding. how to used in proper way. my code are given below: its a negative case. actualy they show 404 response. but when i using 200 they passed this testcase.

it("test case for /hotel/:id/location api", function (done) {
        nock("http://localhost:3010")
            .get('/hotel/1/location')
            .reply(200, {'msg': 'response matched'});
        server
            .get("/hotel/1/location")
            .expect("Content-type", /json/)
            .end(function (err, res) {
                if (res.success == false) {
                    res.status.should.equal(200);
                }
                if (err)
                {
                    res.body.error.should.equal(true);
                }
                done();
            });
    nock.cleanAll();
    });
});
about 4 years ago · Santiago Trujillo
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!