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

153
Vistas
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
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