test a hyper+json API
Last updated 6 years ago by camshaft .
MIT · Original npm · Tarball · package.json
$ cnpm install hypertest 
SYNC missed versions from official npm registry.


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: http://api.example.com

.account.name: should exist

With (optional) headers

host: http://api.example.com
  header1: value1
  header2: value2
.account.name: 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.

host: http://api.example.com


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:

val, value

The value of the body at the end of the path


The response object returned by superagent

path, key

The path used in the test


should.js module used for testing

hyperagent, hyper

hyperagent context used to make the request


CommonJS require function to require any other needed modules

done, cb, fn

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

Current Tags

  • 0.2.1                                ...           latest (6 years ago)

3 Versions

  • 0.2.1                                ...           6 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (0)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |