Testing Overview
@opra/testing makes end-to-end testing of OPRA services straightforward. It provides two main building blocks:
- OpraTestClient — an HTTP client that sends requests directly to your application handler without binding a port. No server startup, no teardown, one call to
.getResponse()and you have the result. - ApiExpect & Matchers — a fluent assertion API attached to every response as
res.expect. Check status, response shape, payload contents, sort order, and error details — all in a single readable chain.
Installation
npm install --save-dev @opra/testing
Quick example
const res = await testClient
.get('/customers')
.param({ limit: 10 })
.getResponse();
res.expect
.toSuccess(HttpStatusCode.OK)
.toReturnCollection()
.toReturnItems(1)
.toMatch({ givenName: 'Jane' });
For setup patterns, request methods, and auth/authorization testing see OpraTestClient.
For the full assertion reference see ApiExpect & Matchers.