@lcdev/router-testing
v1.1.0
Published
Testing framework for @lcdev/router
Downloads
79
Keywords
Readme
router-testing
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.