Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 14, 2024 via pnpm

supertest 6.3.3

SuperAgent driven library for testing HTTP servers
Package summary
Share
0
issues
3
licenses
32
MIT
6
ISC
1
BSD-3-Clause
Package created
26 Jun 2012
Version published
7 Dec 2022
Maintainers
6
Total deps
39
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
32 Packages, Including:
asap@2.0.6
asynckit@0.4.0
call-bind@1.0.7
combined-stream@1.0.8
component-emitter@1.3.1
cookiejar@2.1.4
debug@4.3.4
define-data-property@1.1.4
delayed-stream@1.0.0
es-define-property@1.0.0
es-errors@1.3.0
fast-safe-stringify@2.1.1
form-data@4.0.0
formidable@2.1.2
function-bind@1.1.2
get-intrinsic@1.2.4
gopd@1.0.1
has-property-descriptors@1.0.2
has-proto@1.0.3
has-symbols@1.0.3
hasown@2.0.2
hexoid@1.0.0
methods@1.1.2
mime-db@1.52.0
mime-types@2.1.35
mime@2.6.0
ms@2.1.2
object-inspect@1.13.1
set-function-length@1.2.2
side-channel@1.0.6
superagent@8.1.2
supertest@6.3.3

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
6 Packages, Including:
dezalgo@1.0.4
lru-cache@6.0.0
once@1.4.0
semver@7.6.0
wrappy@1.0.2
yallist@4.0.0

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
qs@6.12.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
ⓘ This is a list of supertest 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
methods1.1.22.42 kBMIT
prod
superagent8.1.2155.11 kBMIT
prod

Visualizations

Frequently Asked Questions

What does supertest do?

SuperTest is a high-level abstraction module for testing HTTP. It's driven by SuperAgent and provides various assertions to be used when testing your HTTP server. It adds simplicity to your tests while still providing the ability to drop down to the lower-level API provided by SuperAgent if needed.

How do you use supertest?

To integrate and use SuperTest, you’ll first need to install it as an npm module and then save it as a development dependency using the command npm install supertest --save-dev. Once installed, it can be called within your code using require('supertest').

Here’s an example of SuperTest in action without using any test framework:

const request = require('supertest');
const express = require('express');

const app = express();

app.get('/user', function(req, res) {
  res.status(200).json({ name: 'john' });
});

request(app)
  .get('/user')
  .expect('Content-Type', /json/)
  .expect('Content-Length', '15')
  .expect(200)
  .end(function(err, res) {
    if (err) throw err;
  });

For the case of enabling http2 protocol, you simply append an options to request or request.agent as shown below:

request(app, { http2: true })
  .get('/user')
  .expect('Content-Type', /json/)
  .expect('Content-Length', '15')
  .expect(200)
  .end(function(err, res) {
    if (err) throw err;
  });

request.agent(app, { http2: true })
  .get('/user')
  .expect('Content-Type', /json/)
  .expect('Content-Length', '15')
  .expect(200)
  .end(function(err, res) {
    if (err) throw err;
  });

SuperTest is also compatible with any test frameworks. An example usage with Mocha is shown below:

describe('GET /user', function() {
  it('responds with json', function(done) {
    request(app)
      .get('/user')
      .set('Accept', 'application/json')
      .expect('Content-Type', /json/)
      .expect(200, done);
  });
});

Where are the supertest docs?

For your reference, you can always resort to the official SuperTest documentation hosted on Github. Make use of these extensive docs to further explore code examples and method descriptions to benefit your project's HTTP testing.