Skip to content

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

Notifications You must be signed in to change notification settings

AndreiCalazans/endpoint-testar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published