# node-mock-http

Latest version **1.0.5** (published 2026-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-mock-http
pnpm add node-mock-http
yarn add node-mock-http
bun add node-mock-http
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2026-07-28 |
| First published | 2025-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 144.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Maintainers | pi0 |

## Links

- npm: https://www.npmjs.com/package/node-mock-http
- Repository: https://github.com/unjs/node-mock-http
- Homepage: https://github.com/unjs/node-mock-http#readme
- Issues: https://github.com/unjs/node-mock-http/issues
- npm.io page: https://npm.io/package/node-mock-http

## Recent versions

- 1.0.5 (latest) — 2026-07-28
- 1.0.4 — 2025-12-04
- 1.0.3 — 2025-09-04
- 1.0.2 — 2025-07-30
- 1.0.1 — 2025-06-25
- 1.0.0 — 2025-02-05
- 0.1.4 — 2025-02-05
- 0.1.2 — 2025-02-05
- 0.1.1 — 2025-02-05
- 0.1.0 — 2025-02-05
- 0.0.0 — 2025-02-05

## README

# node-mock-http

<!-- automd:badges color=yellow -->

[![npm version](https://img.shields.io/npm/v/node-mock-http?color=yellow)](https://npmjs.com/package/node-mock-http)
[![npm downloads](https://img.shields.io/npm/dm/node-mock-http?color=yellow)](https://npm.chart.dev/node-mock-http)

<!-- /automd -->

Node.js [`http.IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) and [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) mocked implementations that allows emulate calling Node.js http handlers. (based on [unjs/unenv v1](https://github.com/unjs/unenv/tree/v1)).

## Usage

> [!NOTE]
> Documentation is incomplete!

```js
import { fetchNodeRequestHandler } from "node-mock-http";

const nodeHandler = (req, res) => {
  res.end("OK!");
};

const res = await fetchNodeRequestHandler(
  nodeHandler,
  "http://example.com/test",
);
```

## Development

<details>

<summary>local development</summary>

- Clone this repository
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Build project in stub mode using `pnpm build --stub`
- Run interactive tests using `pnpm dev`

</details>

## License

<!-- automd:contributors license=MIT -->

Published under the [MIT](https://github.com/unjs/node-mock-http/blob/main/LICENSE) license.
Made by [community](https://github.com/unjs/node-mock-http/graphs/contributors) 💛
<br><br>
<a href="https://github.com/unjs/node-mock-http/graphs/contributors">
<img src="https://contrib.rocks/image?repo=unjs/node-mock-http" />
</a>

<!-- /automd -->

<!-- automd:with-automd -->

---

_🤖 auto updated with [automd](https://automd.unjs.io)_

<!-- /automd -->

---
_Source: https://npm.io/package/node-mock-http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
