Comparing version 6.0.1 to 6.1.0
@@ -68,2 +68,24 @@ 'use strict'; | ||
/** | ||
* Wraps an assert function into another. | ||
* The wrapper function edit the stack trace of any assertion error, prepending a more useful stack to it. | ||
* | ||
* @param {Function} assertFn | ||
* @returns {Function} wrapped assert function | ||
*/ | ||
function wrapAssertFn(assertFn) { | ||
var savedStack = new Error().stack.split('\n').slice(3); | ||
return function(res) { | ||
var badStack; | ||
var err = assertFn(res); | ||
if (err && err.stack) { | ||
badStack = err.stack.replace(err.message, '').split('\n').slice(1); | ||
err.stack = [err.message, savedStack, '----', badStack].flat().join('\n'); | ||
} | ||
return err; | ||
}; | ||
} | ||
/** | ||
* Expectations: | ||
@@ -87,3 +109,3 @@ * | ||
if (typeof a === 'function') { | ||
this._asserts.push(a); | ||
this._asserts.push(wrapAssertFn(a)); | ||
return this; | ||
@@ -96,6 +118,6 @@ } | ||
if (typeof a === 'number') { | ||
this._asserts.push(this._assertStatus.bind(this, a)); | ||
this._asserts.push(wrapAssertFn(this._assertStatus.bind(this, a))); | ||
// body | ||
if (typeof b !== 'function' && arguments.length > 1) { | ||
this._asserts.push(this._assertBody.bind(this, b)); | ||
this._asserts.push(wrapAssertFn(this._assertBody.bind(this, b))); | ||
} | ||
@@ -107,3 +129,3 @@ return this; | ||
if (typeof b === 'string' || typeof b === 'number' || b instanceof RegExp) { | ||
this._asserts.push(this._assertHeader.bind(this, { name: '' + a, value: b })); | ||
this._asserts.push(wrapAssertFn(this._assertHeader.bind(this, { name: '' + a, value: b }))); | ||
return this; | ||
@@ -113,3 +135,3 @@ } | ||
// body | ||
this._asserts.push(this._assertBody.bind(this, a)); | ||
this._asserts.push(wrapAssertFn(this._assertBody.bind(this, a))); | ||
@@ -116,0 +138,0 @@ return this; |
{ | ||
"name": "supertest", | ||
"version": "6.0.1", | ||
"version": "6.1.0", | ||
"description": "SuperAgent driven library for testing HTTP servers", | ||
@@ -35,4 +35,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"methods": "1.1.2", | ||
"superagent": "6.1.0" | ||
"methods": "^1.1.2", | ||
"superagent": "^6.1.0" | ||
}, | ||
@@ -43,8 +43,8 @@ "devDependencies": { | ||
"coveralls": "3.1.0", | ||
"eslint": "7.9.0", | ||
"eslint-config-airbnb-base": "14.2.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint": "7.17.0", | ||
"eslint-config-airbnb-base": "14.2.1", | ||
"eslint-plugin-import": "2.22.1", | ||
"express": "4.17.1", | ||
"mocha": "8.1.3", | ||
"nock": "13.0.4", | ||
"mocha": "8.2.1", | ||
"nock": "13.0.5", | ||
"nyc": "15.1.0", | ||
@@ -51,0 +51,0 @@ "should": "13.2.3" |
@@ -103,3 +103,3 @@ # SuperTest | ||
if (err) return done(err); | ||
done(); | ||
return done(); | ||
}); | ||
@@ -114,3 +114,3 @@ }); | ||
describe('GET /users', function() { | ||
it('responds with json', function() { | ||
it('responds with json', function(done) { | ||
return request(app) | ||
@@ -123,3 +123,5 @@ .get('/users') | ||
assert(response.body.email, 'foo@bar.com') | ||
done(); | ||
}) | ||
.catch(err => done(err)) | ||
}); | ||
@@ -126,0 +128,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20661
380
294
1
Updatedmethods@^1.1.2
Updatedsuperagent@^6.1.0