HTTP routes testing
@marblejs/testing is a tool agnostic module for testing Marble.js apps.
Installation
$ yarn add --dev @marblejs/testingHttpTestBed
import { createHttpTestBed } from '@marblejs/testing';
import { listener } from './http.listener';
const httpTestBed = createHttpTestBed({
listener,
defaultHeaders: {
...
},
});
// then ...
describe('user$', () => {
test('POST "/api/v1/user" creates user', async () => {
const dependencies = [ ... ];
const { request, finish, ask } = await httpTestBed(dependencies);
// 1. initialize testing environment...
// 2. prepare and send test request...
// 3. assert recieved response...
// 4. ... and close connection
await finish();
});
});Dependency injection
Constructing test request
Cleanups
Last updated