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

220
Views
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
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!