{"library":"reqres","title":"reqres","description":"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.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install reqres"],"cli":null},"imports":["const { req } = require('reqres');","const { res } = require('reqres');","const reqres = require('reqres'); reqres.sinon = require('sinon');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { req, res } = require('reqres');\nconst myMiddleware = (req, res, next) => {\n  req.session = req.session || {};\n  req.session.path = req.path;\n  next();\n};\n\nconst mockReq = req({ path: '/test', session: {} });\nconst mockRes = res();\n\nmyMiddleware(mockReq, mockRes, (err) => {\n  console.log(mockReq.session.path); // '/test'\n});","lang":"javascript","description":"Shows creating mock req and res objects with custom properties and invoking middleware.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}