SuperTest
HTTP assertion library for testing Node.js HTTP servers with a chainable, expressive API.
Pricing
Free / Open source
Type
Automation
Languages
JavaScript, TypeScript
// VERDICT
Reach for SuperTest when you want to test a Node.js HTTP API in code, inside your existing JS test runner. Skip it when your stack isn't JS/Node or you want a GUI-based API client.
Best for
Asserting on HTTP endpoints from JavaScript/TypeScript tests, especially Node.js apps, by driving requests inside your test runner.
Avoid when
You're not testing a Node/JS HTTP app, or you want a GUI client or a non-JS language.
CI/CD fit
Jest · Mocha · GitHub Actions · GitLab CI · npm
Languages
JavaScript · TypeScript
Team fit
Node.js teams · JavaScript/TypeScript teams · Backend SDET teams
Setup
Maintenance
Learning
Licence
// BEST FOR
- Testing Node.js/Express-style HTTP APIs directly in code
- Running API assertions inside an existing Jest or Mocha suite
- Testing an app in-process without a separately running server
- Fast, developer-owned API tests versioned with the app
- A fluent request/assertion chain familiar to JS developers
- Combining API checks with the rest of a JS unit/integration suite
// AVOID WHEN
- Your application or stack isn't JavaScript/Node
- You want a GUI client for exploring APIs
- Non-developers need to author or run the tests
- You need code-based tests in another language (REST Assured for Java)
- Cross-language contract testing is the goal (Pact)
- You want a standalone tool decoupled from a JS test runner
// QUICK START
npm install --save-dev supertest
# in a Jest/Mocha test: request(app).get('/health').expect(200)// ALTERNATIVES TO CONSIDER
| Tool | Choose it when |
|---|---|
| REST Assured | You want code-based API tests in Java rather than JS. |
| Postman | You want a GUI client with saved collections. |
| Playwright | You want one tool for API plus browser E2E in JS/TS. |
// FEATURES
- Chainable HTTP request builder built on superagent
- Pass an Express/Koa/Fastify app directly — no listening port required
- Built-in assertions for status, headers, and body
- Cookie and session handling for authenticated flows
- Pairs naturally with Mocha, Jest, Vitest, and Tap
// PROS
- Most popular API testing library in the Node ecosystem
- Zero-port testing speeds up integration tests
- Tiny API surface — fast to learn
- Stable across many years and Node versions
// CONS
- Limited helpers compared to Karate or REST-assured
- Built on superagent, which has its own quirks
- No built-in test data or mocking utilities
// EXAMPLE QA WORKFLOW
Add SuperTest to dev dependencies
Import it into your Jest/Mocha tests, passing the app
Write request/assertion chains against endpoints
Reuse helpers for auth and common setup
Seed test data via API or fixtures
Run as part of the normal JS test step in CI
// RELATED QA.CODES RESOURCES
Cheat sheets
Glossary
Interview