1. should-http
Http requests, response assertions for should.js
should-http
Package: should-http
Created by: shouldjs
Last modified: Sun, 26 Jun 2022 19:05:47 GMT
Version: 0.1.1
License: MIT
Downloads: 12,889
Repository: https://github.com/shouldjs/http

Install

npm install should-http
yarn add should-http

should.js http assertions

Build Status

This module can be usefull for asserting on node standard http modele request and response.

Install

npm install should-http --save-dev
require('should-http');

That row patch your should instance adding assertions. With mocha you can use it via -r switch.

.status(code)

Asserts that .statusCode is code:

 res.should.have.status(200);

.header(field[, value])

Asserts that a .headers object with field and optional value are present:

 res.should.have.header('content-length');
res.should.have.header('Content-Length', '123');

.json

Assert that Content-Type is "application/json; charset=utf-8"

 res.should.be.json

.html

Assert that Content-Type is "text/html; charset=utf-8"

 res.should.be.html

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code