Noodles Practicing Medicine

npm

Need private packages and team management tools?Check out npm Orgs. »

hatest

0.1.2 • Public • Published

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.

Keywords

install

npm i hatest

Downloadsweekly downloads

11

version

0.1.2

license

ISC

last publish

collaborators

  • avatar
Report a vulnerability