mercredi 3 mars 2021

Mocha test false assert timeouts

I have some problem with my async mocha tests. The assert method within a promise results in a timeout when the input evaluates to false. (with true values it works fine)

This is a simplified version of the problem. We usually do networking instead of this constructed promise.

describe('test',  () => {

    it('testcase', (done) => {

        new Promise(async (res) => {

            console.log("before");
            assert(false);
            console.log("after");

            res(null);
        }).then(() => done()).catch(() => done());

    });
});
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

Aucun commentaire:

Enregistrer un commentaire