@tritio/testing
v0.3.1
Published
Testing utilities for Tritio
Downloads
12
Readme
@tritio/testing
Testing utilities for Tritio applications.
Installation
bun add -d @tritio/testingFeatures
- Simple Testing API - Easy-to-use
treatfunction for testing Tritio apps - Type-Safe - Full TypeScript support
- Fast - Built on Bun's test runner
- Zero Config - Works seamlessly with your Tritio apps
Usage
import { describe, test, expect } from 'bun:test';
import { treat } from '@tritio/testing';
import { app } from './app';
describe('API Tests', () => {
test('GET /users returns users list', async () => {
const res = await treat(app).get('/users');
expect(res.status).toBe(200);
const data = await res.json();
expect(data.users).toBeArray();
});
test('POST /users creates a new user', async () => {
const res = await treat(app).post('/users').send({ name: 'John', email: '[email protected]' });
expect(res.status).toBe(201);
});
});API
treat(app: Tritio): TestClient
Creates a test client for your Tritio application.
Methods:
get(path: string)- Make a GET requestpost(path: string)- Make a POST requestput(path: string)- Make a PUT requestdelete(path: string)- Make a DELETE requestpatch(path: string)- Make a PATCH requestsend(data: any)- Set request bodyset(header: string, value: string)- Set request header
License
MIT
