Skip to content

Commit

Permalink
fix(middleware): do not pass next to wrapFn
Browse files Browse the repository at this point in the history
passing next to wrapFn causes nested error stack
  • Loading branch information
thetutlage committed Apr 1, 2017
1 parent be74183 commit de5d1c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/Group.js
Expand Up @@ -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})
}))
}
Expand Down
3 changes: 2 additions & 1 deletion src/Middleware.js
Expand Up @@ -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))
})
Expand Down
5 changes: 2 additions & 3 deletions src/Runner.js
Expand Up @@ -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))
}

/**
Expand Down

0 comments on commit de5d1c4

Please sign in to comment.