kudy-tester
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

kudy-tester

For more convenient testing of kudy routes requests.

For example:

import { default as RouteTester } from "kudy-tester";
import {mockRes} from "sinon-express-mock";
import * as chai from 'chai';
import {mockRes} from "sinon-express-mock";
 
const expect = chai.expect;
 
import GetPostsRoute from "./router/GetPostsRoute";
 
const tester = new RouteTester();
 
it(
    'should call correct status code',
    tester.test(
        new GetPostsRoute(),
        {
            headers: {
                "Authorization": "Bearer XYZ"
            }
        },
        async (res: mockRes.MockRes): Promise<void> => {
            expect(res.sendStatus).to.be.calledWith(200);
        }
    )
);

Parameters:

  • route
    • Instance of tested route.
  • request additional data
    • In default request has set only 2 options method (from route getter method) and url (from route getter fullPath). You can through this parameter pass other (like headers, authentication etc.)
  • test function
    • this function should be async or return promise. It will get final response object as first parameter and you can do here all necessary testing stuff.

Readme

Keywords

none

Package Sidebar

Install

npm i kudy-tester

Weekly Downloads

26

Version

1.0.0

License

MIT

Unpacked Size

7.08 kB

Total Files

6

Last publish

Collaborators

  • scorpio1337