{"library":"should-http","title":"should-http: HTTP Assertions for should.js","description":"should-http extends the `should.js` assertion library with specific methods for validating Node.js HTTP `IncomingMessage` objects. Primarily used for testing HTTP requests and responses, it enables fluent assertions on status codes, headers (e.g., `Content-Length`), and content types (e.g., `application/json`, `text/html`). Currently at version 0.1.1, this package appears to be abandoned, with no active development or maintenance. Its approach of patching the global `should` instance, rather than exporting specific utilities, ties it closely to older `should.js` usage patterns and makes it less suitable for modern module development (ESM) where global side-effects are generally avoided. It focuses specifically on the standard Node.js `http` module's request and response objects, distinguishing it from broader HTTP client assertion libraries.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install should-http"],"cli":null},"imports":["require('should-http');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const should = require('should');\nrequire('should-http');\n\n// Simulate an HTTP response object\nconst mockResponse = {\n  statusCode: 200,\n  headers: {\n    'content-type': 'application/json; charset=utf-8',\n    'content-length': '123'\n  },\n  body: '{ \"key\": \"value\" }'\n};\n\n// Assertions using should-http\ntry {\n  mockResponse.should.have.status(200);\n  console.log('✔ Status code is 200');\n\n  mockResponse.should.have.header('content-length');\n  console.log('✔ Has content-length header');\n\n  mockResponse.should.have.header('Content-Length', '123');\n  console.log('✔ Content-Length header matches value');\n\n  mockResponse.should.be.json();\n  console.log('✔ Content-Type is application/json');\n\n  // Example of a failing assertion (uncomment to see it fail)\n  // mockResponse.should.have.status(404);\n\n} catch (e) {\n  console.error('Assertion failed:', e.message);\n}\n\n// Example for .html (if content-type were different)\nconst htmlResponse = {\n    statusCode: 200,\n    headers: {\n        'content-type': 'text/html; charset=utf-8'\n    }\n};\n\ntry {\n    htmlResponse.should.be.html();\n    console.log('✔ Content-Type is text/html');\n} catch (e) {\n    console.error('HTML assertion failed:', e.message);\n}","lang":"javascript","description":"Demonstrates how to initialize `should-http` and use its core assertions (status, header, json, html) on a mock HTTP response object.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}