Node.js module for performing assertions on HTTP responses
Price: Free / Donations
Node.js module for performing assertions on HTTP responses which are received after sending requests. These assertions can include things like the status code, HTTP headers, response text, XPath expressions, JSON paths etc and are therefore suitable for simple website or API behavior monitoring. Additionally, the response time and other timing metrics are returned together with the test results, which can be handy for tracking performance changes over time (and, if you like, from different geographic locations).
While the module is basically generic, it was written to be used in “Serverless” functions (AWS Lambda, Google Cloud Functions, Azure Functions etc). Doing that using code (as opposed to configuring a monitoring service where you hand-craft checks in the GUI) means that checks can be version-controlled, branched, automatically deployed and both triggered periodically or explicitly, for instance as a smoke test immediately after a deployment.
Requests can be run sequentially or with a configurable concurrency. As the requests are done using the widely known “request” npm module, you can do anything that the “request” module offers (which is a lot), including:
- any HTTP methods
- any content types
- arbitrary headers
- form data
- HTTP authentication
Out of the box, this module is able to:
- Verify response HTTP status code
- Perform checks on response headers
- Perform plaintext content checks for a number of content types (most importantly: HTML)
- Perform checks (either existence, non-existence or content) using CSS selectors
- Perform checks (either existence, non-existence or content) using JSON pointer expressions
- Perform checks (either existence, non-existence or content) using XPath expressions
- Perform checks on the raw response body
- Perform completely arbitrary checks using callback functions
- Record request/response timing information
- In addition, it is possible to write own checks.
For more information, see the module page on npm.