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

116
Vistas
Why is my test case passes but the assertion actually failed in mocha

My test case below passes but my Assertion failed. Why is it passing? I already have async in place and the updateSpy is not even called which is confirmed by my Assertion failed message. I also tried Done with promises.

it('should call the update  method once', async () => {
        const updateSpy = sinon.spy(() => 'Spy!');
    
        sinon.stub(service, 'db').resolves({
          collection(collectionName) {
            return {
              update: updateSpy,

                  };
          },
        });

       console.assert(updateSpy.called); // assertion failed but the test case was passed
  }); 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

From the ASSERTIONS doc:

Mocha allows you to use any assertion library you wish. In the above example, we’re using Node.js’ built-in assert module — but generally, if it throws an Error, it will work!

But console.assert() method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens. It will NOT throw an Error if the assertion is false.

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