Node.js mock / polyfill http object library for http req / res
Node.js mock / polyfill http object library for http req / res.
Polyfill req / res for testing w/o http or for code generation from an existing site.
/* Should consider migrating to a factory so that people don't have to guess whether to use new or not */var MockRequest = require'hammock'RequestMockResponse = require'hammock'Response;/* Most This is most helpful for GET requests. In future, it would be nice to polyfill body parsing events. */var req =url: '/foo'headers: host: 'localhost' bar: 'baz'method: 'GET'res = ;reson'end'console.logdatastatusCode;console.logutilinspectdataheaders;console.logdatabody;;/* Using pipeline-router / director syntax here, but this should be simple with express. */var router = RouterFactorycreate /* options */ ;routerdispatchreq res;