Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

supertest

Package Overview
Dependencies
Maintainers
7
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest - npm Package Compare versions

Comparing version 6.0.1 to 6.1.0

32

lib/test.js

@@ -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;

16

package.json
{
"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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc