Use this file to discover all available pages before exploring further.
The typed test client gives you 100% type-safe access to your server’s entities and services in tests — no path strings, no manual casting, no guessing. Tests use the built-in test runner (vtz test) with assertions from @vertz/test and the typed test client from @vertz/testing.
import { createTestClient } from '@vertz/testing';import { createServer } from '@vertz/server';import { todosEntity } from './entities';import { healthService } from './services';const server = createServer({ entities: [todosEntity], services: [healthService], db,});const client = createTestClient(server);
Pass an entity definition to client.entity() — you get back a fully typed proxy with list, get, create, update, and delete methods:
const todos = client.entity(todosEntity);// create() — body is typed to $create_inputconst created = await todos.create({ title: 'Buy milk' });// created.body.title is string, created.body.id is string// list() — returns ListResult<$response>const list = await todos.list();// list.body.items is typed array, list.body.total is number// get() — body is typed to $responseconst item = await todos.get(created.body.id);// update() — body is typed to $update_inputconst updated = await todos.update(created.body.id, { completed: true });// delete()const deleted = await todos.delete(created.body.id);// deleted.status === 204
Pass a service definition to client.service() — each action becomes a directly callable method:
const health = client.service(healthService);// Actions without body schema — call with no args (or options only)const result = await health.check();// result.body.status is string// Actions with body schema — pass the body as first argconst echo = client.service(echoService);const res = await echo.send({ message: 'hello' });// res.body.echo is string
The body parameter is required only when the action defines a body schema. Actions without a body schema accept an optional { headers } options object.
Create a new client with merged default headers. The original client is not modified:
const authed = client.withHeaders({ authorization: 'Bearer test-token',});// All requests from authed include the authorization headerconst result = await authed.entity(todosEntity).list();
This is useful for testing authenticated endpoints:
When your server is created with db + auth (returning a ServerInstance), the test client automatically uses requestHandler — which routes /api/auth/* requests through the auth handler. No extra configuration needed.
const server = createServer({ entities: [todosEntity], db, auth: { session: { strategy: 'jwt', ttl: '15m' } },});await server.initialize();const client = createTestClient(server);// Auth routes like /api/auth/signup work automatically