api-flipbooks

Handcrafted tool for strict API testing

Usage no npm install needed!

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

README

api-flipbooks

circleci JavaScript Style Guide

Handcrafted tool for strict API testing

For whom

Run synchronous interdependent api analysis based on configurable files. This approach results handy for mimicking user behaviour and analyse API endpoint behaviours in real life cases.

usage

cli

$ npm i -g api-flipbooks
$ api-flipbooks ./flibooks-config-file.js

You can also pass a folder, api-flipbooks will then look for all files matching *.flipbook.js:

$ api-flipbooks ./folder-with-configs

api

Install as dev dependency

$ npm i api-flipbooks -D

Anywhere:

const ApiFlipbooks = require('api-flipbooks')
let myApiFlipboks = new ApiFlipbooks({ target: './target-folder' })

flibook file

The best thing is to take a look at the examples in ./flibooks-examples Every flipbook file is expected to export an Object with the following properties:

module.exports = {

  // title of the flipbook (!) required
  title: 'Title of my flipbook'

  // array of api calls/test to be performed (!) required
  scenes: [
    {
      describe: 'What the scene is doing'
      // http request config  (!) required
      request: {  // 
        // options for node 'http' : 'https' (!) required
        options: {}
        // request body (?) optional
        body: {}
      },

      // validation schemas (!) required
      validation: {
        // expected status code (?) optional
        statusCode: 200,

        // validation schema for response headers as 'key': 'value' (?) optional
        headerSchema: {
          'access-control-allow-credentials': 'true'
        },

        // validation schema for body (?) optional
        bodySchema: {
          // expected body key (?) optional
          schemaKey: {
            // expected variable type for the key as string (?) optional
            _type: 'integer',
            // custom validation as async function should return true or false (?) optional
            should:  async (schemaKey) => { return schemaKey === 10 }
          }
        }
      }
    },

    // lifecycle hooks for this scene (?optional)
    lifecycle: {

      // before the scene is run, access history and scene needs to return the scene (?) optional
      async before (history, scene) {
        return scene
      },

      // after the scene is run, access history and responseBody needs to return history (?) optional
      async after (responseBody, history) {
        return history
      }
    }
  ]
}

current status

Under really heavy development

special thanks

reqres.in for providing test api endpoints