1.0.0 • Published 7 months ago

@monitorapex/api-test-utils v1.0.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
7 months ago

Introduction

Provides authentication and Oracle DB utilities for API testing.

Installation

npm install --save-dev api-test-utils

Config

This library expects config data in a specific format in order to work. In order for the appropriate config to be used, the NODE_ENV environmental variable should be set on the machine in question. If nothing is set, then azure-dev is used by default.

{
  "azure-dev": {
    "apiUrl": "http://dev/your.app.url",
    "authUrl": "http://dev/your.oauth.token.url",
    "db": {
      "user": "myuser",
      "password": "mypass",
      "connectString": "dev.myconnect.string"
    }
  },
  "azure-ci": {
    "apiUrl": "http://ci/your.app.url",
    "authUrl": "http://ci/your.oauth.token.url",
    "db": {
      "user": "myuser",
      "password": "mypass",
      "connectString": "ci.myconnect.string"
    }
  },
}

Usage

Initializing

// To get started get your config...
const envData = require('./config/env.json');

//...and pass your config into apiUtils require
const apiUtils = require('api-test-utils')(envData);

Get an access token

const accessToken = await apiUtils.getAccessToken();

Perform queries/DML

const oracle = apiUtils.Oracle();

oracle.query('UPDATE table SET.....');

// If you need to await the result you can
await oracle.query('UPDATE table SET....');

Access the env config

const config = apiUtils.Config();

config.getValue('apiKey');

Changelog

  • 1.3.2 - Remove caching of access token accross tests.
1.0.0

7 months ago