api-inspect

API inpection library

Usage no npm install needed!

<script type="module">
  import apiInspect from 'https://cdn.skypack.dev/api-inspect';
</script>

README

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
});