Stub request and response objects for testing Express applications and middleware. Provides `req()` and `res()` functions that create mock objects with sensible defaults and sinon stubs on methods. Version 3.0.1 is current, maintained as needed. Key differentiator: integrates sinon for stub/spy assertions, customisable sinon instance, emits 'end' events on response methods. Alternative to node-mocks-http or express-mocks-http.
npm install reqresVerified import paths — ran on the pinned version, not inferred.
Shows creating mock req and res objects with custom properties and invoking middleware.
Provide custom headers via res({ headers: {...} }) or manually set in tests.Use const { req, res } = require('reqres'); then call req(), res().Check source or readme for full list of methods that emit 'end'.
Use CommonJS require() or find an ESM-compatible alternative.
Use const { req } = require('reqres');Run npm install sinon --save-dev
Wrap assertion in res.on('end', ...) callback.