A super-agent driven library for testing Node.js HTTP servers using a fluent API.
Supertest is a Node.js library for testing HTTP servers, built on top of the superagent HTTP client. It provides a fluent, chainable API to make HTTP requests and assert responses, simplifying integration and API testing. It automatically handles server binding and works with any testing framework.
Node.js developers and testers who need to write integration tests for HTTP servers, REST APIs, or Express.js applications.
Developers choose Supertest for its intuitive fluent API, seamless integration with superagent's features, and flexibility to work with any testing framework or plain Node.js scripts.
🕷 Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Chainable methods like .get().expect() enable readable test syntax, as shown in the mocha example where status and content type are asserted in a single chain.
Binds to ephemeral ports if the server isn't listening, eliminating manual port configuration, demonstrated in the initial setup example.
Built-in helpers such as .set() and .not() provide detailed cookie assertions, with examples in the Cookies API section for testing domain, path, and httpOnly flags.
Supports HTTP/2 with a simple { http2: true } flag and inherits features like file uploads from superagent, making it versatile for various HTTP scenarios.
HTTP errors are only passed to callbacks when .expect() for status is omitted, leading to confusing test failures if not managed, as cautioned in the README.
Deep integration with superagent means bugs or changes in superagent directly affect supertest, adding maintenance overhead and potential breaking changes.
Cannot be used for testing in browser environments, limiting its applicability to server-side Node.js applications only.