superjest
A set of Hamjest matchers for user with superagent
Usage
superagent
and hamjest
are peer dependencies, so users of superjest
need to install those modules too.
$ npm install superagent hamjest superjest
Using with superagent
Perform the assertions at the end of the request, however you like to user superagent.
;
Matchers
For examples of the Matchers in action, see the tests.
hasStatusCode
- @param {number} code
Assert that the response has the correct status code.
;
hasHeader
- @param {string} name The header name
- @param {Matcher} [matcher] Optional matcher for the header value
Assert that the response has a header, and that header matches expectations.
;;
hasContentType
- @param {Matcher} matcher
Assert that the response has the correct content type header.
Ignores field parameters
;;
hasCharset
- @param {Matcher} matcher
Assert that the response has the correct charset.
The charset must be specified with a '-'
;
hasContentLength
- @param {Matcher} matcher
Assert that the response has the correct content length header.
;
hasLocation
- @param {Matcher} matcher
Assert that the response has the correct location header.
;
isRedirectedTo
- @param {string} location
Convenience to assertion redirection
;
html
Convenience to return 'text/html' MIME type
json
Convenience to return 'application/json' MIME type
text
Convenience to return 'text/plain' MIME type
Thanks
This library was inspired by chai-http. I just prefer to use hamjest
License
MIT