JSPM

devpunx-api-tests

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q33429F
  • License MIT

Simple api testing module

Package Exports

  • devpunx-api-tests

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (devpunx-api-tests) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ABOUT

Simple api-test module for node.js

INSTALL

npm install devpunx-api-tests

USE

  • Define tests in a json5 file
  • Integrate it in your code or use as standalone

Test definitions

  • protocol: String [http | https]
  • host: String [hostname]
  • port: Number [port] default: port is defined by protocoll [80 | 443]
  • UseBasicAuth: Object
    • username: String
    • password: String default = false
  • tests: Object
    • name: String
    • path: String
    • parameter: Array
    • method: String [GET|POST|PUT|DELETE]
    • expected: Object
      • statusCode: Number

Example:

{
    protocol: 'https',
    host: 'api.icndb.com',
    port: null,
    UseBasicAuth: false,
    tests: {
        "1": {
            name: 'GET /jokes/random',
            path: '/jokes/random',
            parameter: [],
            method: 'GET',
            expected: {
                statusCode: 200
            }
        },
        "2": {
            name: 'GET /asd',
            path: '/asd',
            parameter: ['api_key=mysecret'],
            method: 'GET',
            expected: {
                statusCode: 200
            }
        }
    }
}

Setup and run the tests with the path to test-definition file

// Create new Test
let myTests = new Test([pathname to test-definition file])
// Run the tests
myTests.run()

Example

const Test = require('devpunx-api-tests')

let myTest = new Test(__dirname + '/tests').run()

Test results are shown in the console as table.