SurrealKit includes a testing framework that lets you write declarative test suites for your SurrealDB schema. Tests run against an isolated ephemeral database per suite, so they are safe to run in any environment without affecting persistent data.
Running tests
SurrealKit reads all suite files from database/tests/suites/*.toml, runs them in parallel (configurable), and exits non-zero if any case fails.
Project structure
Global config
database/tests/config.toml sets defaults shared across all suites:
Test types
SurrealKit supports five test types, specified via the kind field on each test case.
sql_expect
Runs a SurrealQL statement and asserts whether it succeeds or fails:
Optional assertions check the returned data:
permissions_matrix
Validates that a single actor has the expected create / select / update / delete permissions on a table or record:
schema_metadata
Asserts structural facts about the schema: that a field exists with a given type, that an index is defined, and so on.
schema_behavior
Tests computed fields, functions, and record relations by asserting on the values returned after specific operations.
api_request
Tests HTTP API endpoints, useful when your SurrealDB instance exposes a custom API layer:
Actors
Each test case runs as a named actor with a specific authentication method. Actors are defined in config.toml or at the suite level.
| Actor kind | When to use |
|---|---|
root | Full root-level access |
database | Database-level user credentials |
record | Record access via signup / signin |
token | JWT token from an environment variable |
headers | Custom HTTP headers (e.g. tenant ID) |
Filtering
| Flag | Description |
|---|---|
--suite <glob> | Run only suites whose name matches the glob |
--case <glob> | Run only cases whose name matches the glob |
--tag <tag> | Run only cases tagged with the given tag (repeatable) |
--fail-fast | Stop on the first failure |
--parallel <N> | Number of parallel execution threads |
Debugging
| Flag | Description |
|---|---|
--keep-db | Preserve the ephemeral database after the run for manual inspection |
--no-sync | Skip the schema sync phase before running tests |
--no-seed | Skip the seeding phase before running tests |
--json-out <path> | Write a machine-readable JSON report to the specified file |
Next steps
CI / CD: integrate tests into automated pipelines with GitHub Actions and Docker Compose