1.1.0 • Published 4 years ago

@lcdev/router-testing v1.1.0

Weekly downloads
1
License
MPL-2.0
Repository
github
Last release
4 years ago

router-testing

Licensed under MPL 2.0 Build Status npm

Testing framework for @lcdev/router.

# replace VERSION below with the most recent major version above (eg. 0.5.1 -> 0.5, 1.2.3 -> 1)
yarn add @lcdev/router-testing@VERSION

Basic usage, assuming you're using jest:

import MyRouteFactory from '../routes/my-route';
import { routerTest } from '@lcdev/router-testing';

test('router does things', async () => {
  await routerTest(MyRouteFactory, { dependency: 'value' }, async (test) => {
    await test.get('/my/route')
      .expect(200).expect({ foo: 23 });

    await test.post('/my/route').send({ values: [11] })
      .expect(200).expect({ dependency: 'value' });

    await test.get('/foo')
      .expect(404);
  });
});

The test object is an instance of supertest with a koa server running only that particular factory.

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago