# kudy-tester

> For more convenient testing of __kudy__ routes requests.

Latest version **1.0.0** (published 2019-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install kudy-tester
pnpm add kudy-tester
yarn add kudy-tester
bun add kudy-tester
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-02-13 |
| First published | 2019-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Antonín Bouchal |
| Maintainers | scorpio1337 |

## Links

- npm: https://www.npmjs.com/package/kudy-tester
- npm.io page: https://npm.io/package/kudy-tester

## Dependencies (19)

- [chai](https://npm.io/package/chai.md) ^4.2.0
- [kudy](https://npm.io/package/kudy.md) ^2.0.0
- [mocha](https://npm.io/package/mocha.md) ^5.2.0
- [sinon](https://npm.io/package/sinon.md) ^7.2.3
- [tslint](https://npm.io/package/tslint.md) ^5.12.1
- [express](https://npm.io/package/express.md) ^4.16.4
- [ts-node](https://npm.io/package/ts-node.md) ^7.0.1
- [typescript](https://npm.io/package/typescript.md) ^3.2.4
- [@types/chai](https://npm.io/package/@types/chai.md) ^4.1.7
- [@types/node](https://npm.io/package/@types/node.md) ^10.12.18
- [@types/mocha](https://npm.io/package/@types/mocha.md) ^5.2.5
- [@types/sinon](https://npm.io/package/@types/sinon.md) ^7.0.5
- [@types/express](https://npm.io/package/@types/express.md) ^4.16.1
- [@types/sinon-chai](https://npm.io/package/@types/sinon-chai.md) ^3.2.2
- [sinon-express-mock](https://npm.io/package/sinon-express-mock.md) ^2.1.0
- [tslint-eslint-rules](https://npm.io/package/tslint-eslint-rules.md) ^5.4.0
- [tslint-config-airbnb](https://npm.io/package/tslint-config-airbnb.md) ^5.11.1
- [tslint-config-prettier](https://npm.io/package/tslint-config-prettier.md) ^1.18.0
- [@types/sinon-express-mock](https://npm.io/package/@types/sinon-express-mock.md) ^1.3.7

## Recent versions

- 1.0.0 (latest) — 2019-02-13
- 0.0.1-dev — 2019-02-12

## README

# kudy-tester

For more convenient testing of __kudy__ routes requests.

__For example:__

```typescript
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.

---
_Source: https://npm.io/package/kudy-tester · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
