@opra/testing
v1.28.5
Published
Opra testing package
Readme
@opra/testing
Testing utilities for the OPRA framework
🌐 Documentation · 🚀 Getting Started · 📦 Packages · 💬 Issues
Testing utilities for the OPRA framework. Write clean, expressive API tests with a fluent assertion API designed for OPRA services.
Features
OpraTestClient— Test client that accepts an HTTP server or request listener directly — no running server neededApiExpect— Chainable assertion class for response validationTestBackend— Lightweight fetch-based backend for test requests- Works with any test runner (Jest, Vitest, Mocha, etc.)
Installation
npm install --save-dev @opra/testingUsage
import { OpraTestClient } from '@opra/testing';
describe('UsersController', () => {
let client: OpraTestClient;
beforeAll(() => {
client = new OpraTestClient(app);
});
it('should return users', async () => {
await client
.get('/users')
.expect(200)
.toSuccess()
.toMatchSchema(User);
});
it('should return 404 for unknown user', async () => {
await client
.get('/users/999')
.expect(404)
.toError('NotFound');
});
});Node Compatibility
- node >= 20.x
License
Available under MIT license.
