Skip to content
Http assertions for should.js
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Rename http-format.test.js to http-format.js Feb 25, 2017
.eslintrc.yml Split nodejs specific things to separate file. Provide alternative br… Mar 22, 2017
.gitignore
.travis.yml Update Feb 6, 2017
History.md
LICENSE Initial version May 29, 2014
Readme.md Update Readme.md Feb 25, 2017
http-node.js Split nodejs specific things to separate file. Provide alternative br… Mar 22, 2017
http.js Split nodejs specific things to separate file. Provide alternative br… Mar 22, 2017
index-browser.js Split nodejs specific things to separate file. Provide alternative br… Mar 22, 2017
index.js Split nodejs specific things to separate file. Provide alternative br… Mar 22, 2017
package.json

Readme.md

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.

This module have built in formatting for node http IncommingMessage's.

.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"

res.should.be.json()

.html()

Assert that Content-Type is "text/html"

res.should.be.html()

.xml()

Assert that Content-Type is "application/xml"

res.should.be.xml()

.contentType(type [, charset])

Assert that Content-Type is a given type with optional charset

res.should.have.contentType('application/xml');
You can’t perform that action at this time.