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

224
Vistas
Tests in jest with done fail when they should succeed (because a done failed in a previous test?)

I have a test that contains many done functions. I assumed that in the case of a failed test, only this test would be displayed as faulty. Now I notice that not only one test is displayed as faulty, but all following tests that contain done are displayed as faulty.

Why is this the case? This makes it difficult to find out the faulty test later.

This is successful

    describe('Map#isRotating', () => {
    test('returns false by default', done => {
        const map = createMap();
        expect(map.isRotating()).toBe(false);
        map.remove();
        done();
    });

    test('returns true during a camera rotate animation', done => {
        const map = createMap();

        map.on('rotatestart', () => {
            expect(map.isRotating()).toBe(true);
        });

        map.on('rotateend', () => {
            expect(true).toBe(false);
            map.remove();
            done();
        });

        map.rotateTo(5, {duration: 0});
    });

    test('returns true when drag rotating', done => {
        const map = createMap();

        // Prevent inertial rotation.
        jest.spyOn(browser, 'now').mockImplementation(() => { return 0; });

        map.on('rotatestart', () => {
            expect(map.isRotating()).toBe(true);
        });

        map.on('rotateend', () => {
            expect(map.isRotating()).toBe(false);
            map.remove();
            done();
        });

        simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2});
        map._renderTaskQueue.run();

        simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10});
        map._renderTaskQueue.run();

        simulate.mouseup(map.getCanvas(),   {buttons: 0, button: 2});
        map._renderTaskQueue.run();
    });
});

All tests with done are fail if I change the first test

    describe('Map#isRotating', () => {
    test('returns false by default', done => {
        const map = createMap();
        expect(true).toBe(false);
        map.remove();
        done();
    });
about 4 years ago · Juan Pablo Isaza
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