mercredi 19 août 2015

Mocha async tests, calling done() issue

I'm developing postcss plugin and want to test it with mocha. Here is my test:

function exec(cb) {
    postcss()
        .use(regexp)
        .process(source)
        .then(cb);
}

it('should add warnings to messages', function(done) {
    var expected = 'somemessage';
    var message = '';

    function getMessage(result) {
        message = result.messages;
        assert.equal(message, expected);
        done();
    }

    exec(getMessage);
});

But it fails and I get Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire