Thursday 13 April 2017

Testing Async Functions With Mocha

I'm using MochaJS for tests of my NodeJS application.

I have a someFunc() function and that function is like that:

function someFunc(cb) {
    // Do some async works...
    // When async works finish
    if(err) // if there is error
        cb(err);
    else
        cb();
}

And testing it like this:

it('...', function(done) {
    className.someFunc(function(err) {
      if (err) done(err);
      else done();
    });
});

But I'm still getting this error:

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

I'm using done() function inside a callback function. Is it a problem?



via Eray

No comments:

Post a Comment