Skip to main content
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.

Entity proxy

Pass an entity definition to client.entity() — you get back a fully typed proxy with list, get, create, update, and delete methods:

List options

The list() method accepts filter, sort, pagination, and field selection options:

Service proxy

Pass a service definition to client.service() — each action becomes a directly callable method:
The body parameter is required only when the action defines a body schema. Actions without a body schema accept an optional { headers } options object.

TestResponse

Every method returns a TestResponse<T> — a discriminated union on ok:

Custom headers

Per-request headers

Pass headers in the options for any method:

Default headers with withHeaders()

Create a new client with merged default headers. The original client is not modified:
This is useful for testing authenticated endpoints:

Raw HTTP methods

For endpoints not covered by entity/service proxies, use the raw HTTP methods:
Available methods: get, post, put, patch, delete, head.

Auth-enabled servers

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.

Full example

Next steps

Test Runner

Built-in test runner with Vitest-compatible API, watch mode, and coverage.

E2E Testing

Browser-based tests with Playwright and authenticated users.

Entities

Define entities with models, access rules, and hooks.

Services

Custom service actions with typed input/output.

Authentication

Session config, stores, and access control.