From caaa11c2eb98d0c81cef172d226f42e689bf2b83 Mon Sep 17 00:00:00 2001 From: Corbin Uselton Date: Mon, 1 May 2017 00:36:31 -0700 Subject: [PATCH] Ignore while a promise returns inside a test with a value. Only watch for rejection Simplify Try again --- lib/runner.js | 2 +- test/runner.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/runner.js b/lib/runner.js index c5253c26..43ac1c11 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -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'); diff --git a/test/runner.js b/test/runner.js index 9152fc65..01246664 100755 --- a/test/runner.js +++ b/test/runner.js @@ -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 });