Title here
Summary here
Mocha’s tests or hooks (like before) may be asynchronous by either returning a Promise or specifying a callback parameter for the function. It can be confusing to have both methods used in a test or hook, and from Mocha v3 on, causes the test to fail in order to force developers to remove this source of confusion.
This rule looks for every test and hook (before
, after
, beforeEach
and afterEach
) and reports when the function takes a parameter and returns a value. Returning a non-Promise value is fine from Mocha’s perspective, though it is ignored, but helps the linter catch more error cases.
describe('suite', function () {
before('title', function(done) {
return foo(done);
});
it('title', function(done) {
return bar().then(function() {
done();
});
});
});
describe('suite', function () {
before('title', function(done) {
foo(done);
});
it('title', function() {
return bar();
});
});
before
, after
), you should turn this rule off, because it would raise warnings.