Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-mock-http

unjs7.2mMIT1.0.2TypeScript support: included

readme

node-mock-http

npm version npm downloads

Node.js http.IncomingMessage and http.ServerResponse mocked implementations that allows emulate calling Node.js http handlers. (based on unjs/unenv v1).

Usage

[!NOTE] Documentation is incomplete!

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

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

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

Development

<summary>local development</summary>
  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Build project in stub mode using pnpm build --stub
  • Run interactive tests using pnpm dev

License

Published under the MIT license. Made by community 💛


🤖 auto updated with automd

changelog

Changelog

v1.0.2

compare changes

🩹 Fixes

  • Correct AsyncIteratorPrototype retrieval in events polyfill (#11)

🏡 Chore

❤️ Contributors

v1.0.1

compare changes

🩹 Fixes

  • Add missing res.writableAborted prop (bd1f26a)
  • Move writableAborted to stream/writable (5384bc2)

🏡 Chore

❤️ Contributors

v1.0.0

compare changes

🏡 Chore

❤️ Contributors

  • Pooya Parsa (@pi0)