unexpected-http
This plugin provides assertions allowing HTTP requests to be declaratively specified which are issued and the responses checked against expectations.
Works with node.js and in browsers via browserify (see example).
Request Syntax
Unexpected-HTTP has a declarative syntax for specifying requests to perform.
String
A single string of the form <method> <url>
that will be parsed and the appropriate
request issued - see string assertion.
describe('unexpected.js.org', function () {
it('should respond', function () {
return expect('GET http://unexpected.js.org/', 'to yield response', 200);
});
});
Object
An object containing the request properties to be executed - see object assertion.
describe('google.com', function () {
it('should respond appropriately disallowing POST', function () {
return expect({
url: 'http://google.com/',
method: 'POST'
}, 'to yield response', 405);
});
});
License
Unexpected-http is licensed under a standard 3-clause BSD license -- see the LICENSE
file for details.