{"library":"mock-express-request","title":"Mock Express Request","description":"Mock Express Request is a Node.js library designed to create mock HTTP request objects for unit testing Express.js applications. It is based on the `mock-req` package and aims to provide an instance with properties and methods similar to a real Express HTTP request. The package is currently at version 0.2.2 and appears to be abandoned, with no significant updates or maintenance activity in approximately nine years. Due to its age, it lacks modern features such as native ES Module support and deep integration with contemporary testing frameworks like Jest, making it less suitable for current Node.js and Express.js projects. Developers are generally advised to consider more actively maintained alternatives like `node-mocks-http` or `@jest-mock/express` for robust testing in modern environments.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install mock-express-request"],"cli":null},"imports":["const MockExpressRequest = require('mock-express-request');","const request = new MockExpressRequest({ method: 'GET', url: '/test' });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const MockExpressRequest = require('mock-express-request');\n\n// Basic usage: Create a mock GET request to a specific URL\nconst basicRequest = new MockExpressRequest({\n    method: 'GET',\n    url: '/api/users/123?profile=full'\n});\n\nconsole.log(`Method: ${basicRequest.method}`); // Expected: GET\nconsole.log(`URL: ${basicRequest.url}`);       // Expected: /api/users/123?profile=full\nconsole.log(`Path: ${basicRequest.path}`);     // Expected: /api/users/123\nconsole.log(`Query 'profile': ${basicRequest.param('profile')}`); // Expected: full\n\n// More advanced usage: Mock a PUT request with headers and cookies\nconst advancedRequest = new MockExpressRequest({\n    method: 'PUT',\n    url: '/data/item/abc',\n    cookies: { session_id: 'MY_SESSION_TOKEN', remember_me: 'true' },\n    headers: {\n        'Accept': 'application/json',\n        'Content-Type': 'application/json',\n        'Authorization': 'Bearer ABCDEFG'\n    },\n    body: { name: 'New Item', value: 42 }\n});\n\nconsole.log(`Host: ${advancedRequest.hostname}`); // Access Express-like properties (often defaults to 'localhost')\nconsole.log(`Request body: ${JSON.stringify(advancedRequest.body)}`);\nconsole.log(`Cookie 'session_id': ${advancedRequest.cookies.session_id}`);\nconsole.log(`Header 'Content-Type': ${advancedRequest.get('Content-Type')}`); // Using .get() for headers","lang":"javascript","description":"Demonstrates how to create basic and advanced mock Express HTTP request objects, configuring method, URL, headers, cookies, and body, then accessing these properties.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}