diff --git a/src/Group.js b/src/Group.js index 01a7d4b..701e667 100644 --- a/src/Group.js +++ b/src/Group.js @@ -66,13 +66,12 @@ class Group { * Wraps the test/hook as a middleware fn * * @param {Object} fn - * @param {Promise} next * @return {Promise} * * @private */ - _wrapFn (fn, next) { - return new Promise((resolve, reject) => fn.run().then(next).then(resolve).catch((error) => { + _wrapFn (fn) { + return new Promise((resolve, reject) => fn.run().then(resolve).catch((error) => { reject({title: fn._title, error: error}) })) } diff --git a/src/Middleware.js b/src/Middleware.js index a8453d7..276bf57 100644 --- a/src/Middleware.js +++ b/src/Middleware.js @@ -51,7 +51,8 @@ class Middleware { const fn = this._stack[index] return new Promise((resolve, reject) => { - this._fnWrapper(fn, next => this._dispatch(index + 1)) + this._fnWrapper(fn) + .then(() => this._dispatch(index + 1)) .then(resolve) .catch((error) => this._internalRejection.bind(this)(index, resolve, reject, error)) }) diff --git a/src/Runner.js b/src/Runner.js index b06597b..e320625 100644 --- a/src/Runner.js +++ b/src/Runner.js @@ -145,13 +145,12 @@ class Runner { * Wraps the group.run as a middleware function. * * @param {Function} - * @param {Function} * @return {Promise} * * @private */ - _wrapFn (fn, next) { - return new Promise((resolve, reject) => fn.run().then(next).then(resolve).catch(reject)) + _wrapFn (fn) { + return new Promise((resolve, reject) => fn.run().then(resolve).catch(reject)) } /**