diff --git a/src/lib/unit/caller.js b/src/lib/unit/caller.js index a11d8cc..639e19f 100644 --- a/src/lib/unit/caller.js +++ b/src/lib/unit/caller.js @@ -2,10 +2,11 @@ const { isPromise } = require('../../util'); const caller = (test, state) => { - let value, error; + let value, error, errored; try { value = test(state); } catch (e) { + errored = true; error = e; } @@ -13,12 +14,13 @@ const caller = (test, state) => { if (promise) { return value - .then(res => ({ resolve: res, promise: true })) - .catch(rej => ({ rejection: rej, promise: true })); + .then(res => ({ status: 'ok', resolve: res, promise: true })) + .catch(rej => ({ status: 'notOk', rejection: rej, promise: true })); } else { return Promise.resolve({ - ...(!error && {value}), - ...(error && {error}), + status: errored ? 'notOk' : 'ok', + ...(!errored && { value }), + ...(errored && { error }), promise: false, }); } diff --git a/src/runner/index.js b/src/runner/index.js index d2155b7..6166f09 100644 --- a/src/runner/index.js +++ b/src/runner/index.js @@ -1,5 +1,3 @@ -const Promise = require('bluebird'); - const { flatten } = require('../util'); const logger = require('../lib/logger'); diff --git a/src/strategy/index.js b/src/strategy/index.js index c7cf5c2..aede770 100644 --- a/src/strategy/index.js +++ b/src/strategy/index.js @@ -1,5 +1,3 @@ -const Promise = require('bluebird'); - const requireDeep = require('../util/requireDeep'); const Runner = require('../runner'); @@ -40,9 +38,11 @@ class Strategy { * @param {string|Array=} options.pattern */ fetchSpecs (options) { - this.__await__.push(Promise.map(requireDeep(options), each => { - this.__gunnerInstances = this.compiler(this)(each); - })); + this.__await__.push( + Promise.all( + requireDeep(options).map( + each => this.__gunnerInstances = this.compiler(this)(each) + ))); return this; } diff --git a/src/util/requireDeep.js b/src/util/requireDeep.js index 1a3d4b7..e58d929 100644 --- a/src/util/requireDeep.js +++ b/src/util/requireDeep.js @@ -1,4 +1,3 @@ -const Promise = require('bluebird'); const fs = require(`fs`).promises; const { map, diff --git a/src/util/symbols.js b/src/util/symbols.js index 602537c..4ada13f 100644 --- a/src/util/symbols.js +++ b/src/util/symbols.js @@ -3,6 +3,8 @@ module.exports = { Start : Symbol('Start'), End : Symbol('End'), + expect: Symbol('expect'), + pass: 'pass', fail: 'fail',