ben-page / node-test

A simple, asynchronous test runner for Node.js.
https://www.npmjs.com/package/node-test
MIT License
4 stars 1 forks source link

auto adjust done() callback to second arg if no state? #17

Closed ghost closed 8 years ago

ghost commented 8 years ago

Isn't easier and less confusing if there is no state - hooks - that done is the second arg?

// no hooks
suite.test('should pass', (t, state, done) => {
    return new Promise(resolve => {
        t.pass();
        resolve();
    }).then(done);
});

// Less confusing would be ( now this throws undefined)
suite.test('should pass', (t, done) => {
    return new Promise(resolve => {
        t.pass();
        resolve();
    }).then(done);
});

And as you may notice in the example above, the done() callback are invoked AFTER the promise are resolved. Is that normal? No errors thrown.

Or should both Promise.resolve and done() be used together?

ghost commented 8 years ago

Closing this. Has been solved I guess?