Skip to content

Commit

Permalink
Ignore while a promise returns inside a test with a value. Only watch…
Browse files Browse the repository at this point in the history
… for rejection

Simplify

Try again
  • Loading branch information
corbinu committed May 1, 2017
1 parent 13c2824 commit caaa11c
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 caaa11c

Please sign in to comment.