Skip to content

Commit

Permalink
Merge pull request #701 from corbinu/master
Browse files Browse the repository at this point in the history
Ignore while a promise returns inside a test with a value. Only watch for rejection
  • Loading branch information
geek authored May 1, 2017
2 parents 13c2824 + caaa11c commit f89a574
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ internals.protect = function (item, state, callback) {
if (itemResult &&
itemResult.then instanceof Function) {

itemResult.then(done, done);
itemResult.then(() => done(), done);
}
else if (!item.fn.length) {
finish(new Error(`Function for "${item.title}" should either take a callback argument or return a promise`), 'function signature');
Expand Down
18 changes: 18 additions & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,24 @@ describe('Runner', () => {
});
});

it('should not fail test that returns a resolved promise with a value', (done) => {

const script = Lab.script({ schedule: false });

script.test('a', () => {

return Promise.resolve('a');
});

Lab.execute(script, {}, null, (err, notebook) => {

expect(err).not.to.exist();
expect(notebook.tests).to.have.length(1);
expect(notebook.failures).to.equal(0);
done();
});
});

it('should not fail test that calls the callback without an error', (done) => {

const script = Lab.script({ schedule: false });
Expand Down

0 comments on commit f89a574

Please sign in to comment.