api-inspect

0.1.2 • Public • Published

API inpection library

Build Status

Install

$ npm install api-inspect

Usage

let apiInspect = require('api-inspect');
let inspect = require('inspect.js');
 
apiInspect.get('http://example.com/api/info').test((ctx) => {
  ctx.statusCode(200);
  ctx.responseTime(50);
  ctx.contentType('application/json');
 
  inspect(ctx.body).isJSON();
  inspect(ctx.body).isEql({
    state: 'OK',
    version: 'v1.0.1'
  });
});

Call express routes

let apiInspect = require('api-inspect');
let app = express(); // gets express app anywhere
 
apiInspect.setApi(app);
apiInspect.get('/api/info').test(ctx => {
  // do your tests
});
 
// API calls to the internet will still work
apiInspect.get('http://inspectjs.com/test').test(ctx => {
  // do your tests
});

Package Sidebar

Install

npm i api-inspect

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

12.9 kB

Total Files

9

Last publish

Collaborators

  • andifeind