Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including hatest with all npm packages installed. Try it out:

var hatest = require("hatest")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hatest v0.1.2

A node API testing tool similar to Supertest, based on Axios.

hatest

HaTest

A node API testing tool similar to Supertest, based on Axios.

Getting Started

Install Hatest as an npm module and save it to your package.json file as a development dependency:

npm i hatest --save-dev

Once installed it can now be referenced by simply calling require('hatest')

Example

Hatest works with mocha, here is an example:

const hatest = require('hatest')
const express = require('express')
 
describe('simple', function() {
    it('test1', function () {
        const app = express()

        app.get('/', function(req, res) {
            res.send('hello')
        })

        return request(app)
            .get('/')
            .expect('hello')
            .end()
    })
})

API

  • .expect(200)

  • .expect(200, body)

  • .expect('Some body')

  • .expect({ someStr: String })

  • .expect('Content-Type', 'application/json')

  • .expect(fn)

  • .end(fn)

Notes

Inspired by supertest.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free