
[![NPM version][npm-badge]][npm-url]
Mock 'http' objects for testing [Express][express-url], [Next.js][nextjs-url] and [Koa][koa-url] routing functions,
but could be used for testing any [Node.js][node-url] web server applications that have code that requires mockups of the request and response objects.
Installation
This project is available as a
[NPM package][npm-url].
$ npm install node-mocks-http --save-dev
$ npm install @types/node @types/express --save-dev # when using TypeScript
or
$ yarn add node-mocks-http --dev
$ yarn add @types/node @types/express --dev # when using TypeScript
After installing the package include the following in your test files:
const httpMocks = require('node-mocks-http');
[release-notes]: https://github.com/eugef/node-mocks-http/releases
[npm-badge]: https://badge.fury.io/js/node-mocks-http.png
[npm-url]: https://www.npmjs.com/package/node-mocks-http
[express-url]: https://expressjs.com
[nextjs-url]: https://nextjs.org
[koa-url]: https://koajs.com
[node-url]: http://www.nodejs.org
[node-http-module-url]: http://nodejs.org/docs/latest/api/http.html