Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 816 Bytes

README.md

File metadata and controls

47 lines (32 loc) · 816 Bytes

Endpoint-Testar


Lightweight function helper to test the result of an endpoint against a type model.

Usage:

Install yarn add endpoint-testar

// @flow

import { endpointTestar, types } from 'endpoint-testar';
const t = types;

type EndpointTestar = (response: Object, dataType: Object, nullables?: Array<string>) => Array<string>;

const FetchResult = {
  name: 'what ever',
  age: '23',
  doc: [{
    number: 100,
  }]
};

const DataTypes = {
    name: t.string,
    age: t.number,
    doc: [{
        number: t.number,
    }]
};

const checkForErrors = () => endpointTestar(FetchResult, DataTypes); // ['age returned 23 we expected type number']

Take a look at the test files for a better understanding

TODO:

  • improve README.
  • improve performance.
  • Add flow types.