A simple, promise-based HTTP server for integration testing in Node.js. v3.0.0 provides an async factory function that starts a server on a random port and returns an object with `baseUrl` and `shutdown()` method. It supports automatic shutdown and collects request body as Buffer. Unlike alternatives like `nock` or `supertest`, this uses a real HTTP server, making it suitable for end-to-end API testing. Released with TypeScript definitions. Maintenance mode since 2022.
npm install http-test-serverNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a server that echoes the request URL, sends a GET request, and shuts down.
Use `await httpTestServer(handler)` to obtain the server object.
Access `req.body` inside the request handler; it will be a Buffer if the client sends a body.
Use URL constructor: `new URL('/foo', server.baseUrl).href` to avoid double slashes.No action needed; the OS assignes a free port automatically.
Use `import httpTestServer from 'http-test-server'` (default import).
Add `await` before httpTestServer: `const server = await httpTestServer(...)`.
Ensure the server promise resolves before using server.baseUrl.