node package manager


test a hyper+json API


test a hyper+json api interface

$ npm install -g hypertest
$ hypertest path/to/test.spec.yml
  4 passing (2s)

hypertest(1) accepts the same flags as mocha

See format for details.

hypertest expects a yaml document describing the tests. A document includes the host name, optional headers and a set of paths with one or more assertions.

The most basic assertion is a simple string. The available methods are described by should.js

host: should exist

With (optional) headers

  header1: value1
  header2: value2 should exist

Additionally, reference to environment variables is possible

host: $HOST
  authorization: $AUTH_TOKEN

Since should exist is so common it is the default assertion.


Assertions can also be a list of assertion statements.
  - should eql 'Frank'
  - should startWith 'F'
  - should endWith 'nk'
  - should be type 'string'
  - should be a String

If more complex assertions are needed inline javascript functions are available.
  - !!js/function >
    function(value, done) {
      // complex testing here

The function can also be given a human-readable name.
    name: should do some really complex thing
    fn: !!js/function >
      function(value, done) {
        // complex testing here

The values for the custom functions get injected in by reading the names of the arguments specified. A list of default values includes:

The value of the body at the end of the path

The response object returned by superagent

The path used in the test

should.js module used for testing

hyperagent context used to make the request

CommonJS require function to require any other needed modules

Function to be called when the assertions are done executing. This is required for any async assertions.