Skip to content

Testing

TypeDBLite is tested at four levels. Specs test the language library, tests test the engine, the conformance report card measures the engine against TypeDB’s own specification, and an end-to-end suite tests the editor inside a real VS Code. This page says what each suite proves and when to run it.

From the repository root:

Terminal window
npm test # every project's test target
npm exec nx -- run typedblite-runtime:test # one project
npm exec nx -- run typedblite-runtime:test -- interpreter # files matching a name

The Nx project names are typeqlite-language, content-revision, typedblite-runtime, typedblite-conformance, typedblite (the CLI), typeqlite-vscode, sync-demo and playground.

Every suite runs on Vitest, with a 30-second timeout per test. Set CI=true to collect coverage into coverage/<project>/, with an 80% floor on statements, lines and functions in every project.

What the floor leaves out, and why. A file is excluded only by name, in its project’s vitest.config.ts, and only when it runs inside a host the unit runner does not provide: VS Code’s extension host, a browser or its workers, Electron, a live TypeDB server, or a separate process. Each entry says where that code IS run (the e2e suite, sync-demo:test-browser, playground:test-browser, the differential oracle). Code that can be unit-tested is tested, not excluded. vscode’s modules that import vscode are tested against test/fakes/vscode.ts.

Project Files What it proves
typeqlite-language libs/language/test/*.spec.ts The grammar parses what it should; the validator refuses what it should; formatting, highlighting, scope, navigation, completion and rename behave. spec-backgrounds.spec.ts parses every Background of TypeDB’s specification, and production-schemas.spec.ts parses the schemas in test-fixtures/schemas/
content-revision libs/content-revision/src/lib/*.spec.ts Revisions are deterministic, and the canonical encoding cannot be forged
typedblite-runtime libs/runtime/test/*.test.ts The engine: schema rules, writes, every query construct, transactions, diagnostics, storage migration, the change log, replication, and full-text search
typedblite-conformance libs/conformance/test/*.test.ts The report card has not regressed, plus the harness itself
typedblite apps/cli/test/*.test.mts The CLI. repl.test.mts spawns the real binary and pipes input into it
typeqlite-vscode apps/vscode/test/*.test.ts The manifest matches the language library, and the bundled language server answers over stdio
playground apps/playground/test/, apps/playground/test-browser/ The browser playground. The unit tests run runProgram on node:sqlite, the examples, share links, the runner’s timeout, the static server’s path-traversal guard, and the language server over the real LSP in Node. test-browser runs the page in Chromium: the engine in a worker, nothing requested from another origin, a program’s text shown as text, and the Monaco editor driven by the language server. Names colored by what they resolve to, squiggles, completion, hover and formatting each fail if the LSP client is switched off (keyword colors need no server, and are checked without one)
sync-demo apps/sync-demo/test/smoke.test.ts The sync demo’s story with headless devices, a real hub process and the real switchboard: convergence after every network event. test-browser adds the PWA in Chromium, the Electron app, and the whole story headless

Before you open a pull request, run the full gate from a clean tree:

Terminal window
npm run gate # everything below
npm run gate -- --quick # the first six steps only

tools/gate.mjs runs, in order, and stops at the first failure: clean (every out/, every *.tsbuildinfo, coverage/), build, typecheck, package contents (what npm publish would ship, npm run check-packages), API (the API reference builds cleanly and every type it mentions is exported, npm run check-api), test with CI=true (so the 80% coverage floor and the conformance report card both apply), the WASM suite, the engine’s browser suite, the playground in Chromium, the website (built, with every internal link followed), the VS Code e2e, and the clean-room install (npm run clean-room: the npm tarballs installed in an empty directory and used; see Releasing), and the five-minute tour (npm run tour: the guide’s commands and files run as written, from the tarballs; see The tour). It sets NX_SKIP_NX_CACHE, so no task is replayed from a cache. The last seven are skipped by --quick. The browser suites need Playwright’s Chromium, the e2e a display, and the clean room the npm registry, for the packages’ dependencies.

GitHub Actions is off for now, so this is the only check. It covers the one Node and OS you run it on; CI used to cover Node 22.16, 22 and 24 on Linux and Node 24 on Windows and macOS. For a change that touches paths, child processes, file handles or Node-version behavior, try it on another if you can.

🔴 Why clean. build is tsc -b, which is incremental. A library whose sources did not change is not rebuilt, so the packages that depend on it are checked against stale type declarations, even with --skip-nx-cache. A dependency upgrade once hid a real type error for a whole phase of work in exactly this way. After any change to dependencies or to a public type, a clean build is the only build you can trust.

libs/conformance vendors TypeDB’s behavior specification (its query/language features, pinned in spec/PIN) and runs every scenario against the engine (ADR-005).

Terminal window
npm exec nx -- run typedblite-conformance:test # fails on any regression
npm exec nx -- run typedblite-conformance:report # prints the full card and a digest of failures

Each scenario has one of four outcomes: pass, fail, deviation (declared in deviations.yaml, with an owner), or not applicable (declared in not-applicable.yaml). The current numbers are in CONFORMANCE.md.

baseline.json is a floor. It records the passing count for each feature file.

  • A count below its floor fails the run. Fix the regression. Never lower the floor to make a change pass.
  • A count above its floor also fails test, with ⬆ above baseline — raise it. Raise the number in baseline.json by hand, in the same commit as the improvement. That way the floor always reflects what main actually achieves.
  • A deviation that starts passing is reported as ✅ deviation now passing. Remove its entry in the same commit.

Declaring a deviation needs an owner: an ADR, or a defect record. Declare one only once the scenario’s Background passes and the deviation is the real reason it fails. The rules are in the TypeDBLite Conformance Standard and the conformance README.

Never edit the vendored .feature files. To move to a newer specification, re-vendor at a new commit, update PIN, and re-run the whole card.

When it is unclear what TypeDB does, ask TypeDB. The oracle runs the same Cucumber steps against a live TypeDB server and prints where the two disagree:

Terminal window
docker run -d --name typedb-oracle --restart always -p 8000:8000 typedb/typedb:3.10.4
cd libs/conformance
npx tsx --tsconfig ../../tsconfig.base.json src/oracle.ts match:948 fetch

Arguments filter by feature, or by feature and line. TYPEDB_URL overrides the default http://localhost:8000. A scenario that TypeDB itself fails is a deviation owned by ADR-007, not a bug in TypeDBLite. The oracle needs a server, so it is never part of the routine run.

Terminal window
npm exec nx -- run typeqlite-vscode:e2e

This packages the extension and the TypeQLite Theme Bridge as .vsix files, downloads VS Code, installs both into a fresh profile, and runs the cases in apps/vscode/e2e/suite.ts inside the real editor. It needs a display: use xvfb-run on a headless machine. Run it whenever you change something an editor sees. That includes any change to the language library’s providers.

ADR-009 makes WASM SQLite a supported binding. Two targets prove it:

Target What it proves
typedblite-runtime:test-wasm The whole runtime suite on @typedblite/runtime/wasm, in Node. The interpreter’s #default-opener is aliased to the WASM opener, and no test is edited. Tests that need a real file on a real disk are excluded by name, with the reason, in vitest.wasm.config.ts: a second connection inspecting the file, another process on the same file, and WAL
typedblite-runtime:test-browser The engine in a real Chromium, on OPFS. A store survives closing the whole browser, a duplicate key is refused with [CNT9], and 🔴 every revision the browser computes equals the one Node computes for the same writes. Needs Playwright’s Chromium (npx playwright-core install chromium)

Run both after any change to the binding interface, wasm.ts, or content-revision.

typedblite-runtime:test-oracle compares full-text search with an external search index, the one a documentation-store project used. It needs that index running, so it is not part of the routine run.

🔴 Nothing compares the change log’s conflict semantics with CouchDB’s any more. A CouchDB revision-tree parity suite once lived in that configuration, and was removed in 2026-09. Treat changes to change-log.ts and content-revision with corresponding care, and cover them with runtime tests. The revision hash is pinned: sha256.spec.ts proves it identical to the node:crypto digest every existing store was written with.

  • Put the test where the behavior lives. Grammar and validator rules go in libs/language/test, engine behavior in libs/runtime/test.
  • File names: *.spec.ts in the language library, *.test.ts in the runtime, conformance and extension, and *.test.mts in the CLI.
  • Assert on diagnostic codes, not messages. Codes are stable API; messages are for people and will be improved.
  • Test the refusal, not just the success. Every construct has inputs it must refuse. Fail-loud is the design (Architecture), so test it.
  • A multi-document language test uses the harness in libs/language/test/workspace.ts, which builds several files into one workspace with an in-memory file system.
  • Shared schemas for several suites live in test-fixtures/schemas/.
  • Prove a test can fail. For a new provider or rule, briefly disable it and confirm the test goes red. A test that cannot fail proves nothing.
  • Differential tests compare two implementations that must agree. For example, relation-join-planning-differential.test.ts runs the planned and unplanned engines and asserts the same rows in the same order. Prefer this shape whenever you add an optimization.
  • Count work, do not time it. To guard performance, assert on lastQueryTrace() counts, as in query-trace.test.ts. Timings are flaky; counts are not. When the cost is a scan the trace does not count, assert on SQLite’s own plan, as full-text-key.test.ts does with EXPLAIN QUERY PLAN. Timings belong to the load test, nx run typedblite-runtime:bench (Performance), which writes them to a results file.

docs/guides/five-minute-tour.tql.md is a notebook (a Markdown file whose typeql fences are cells, ADR-012) and also the page on GitHub and the website. It is tested by playing it as a reader does, in layers, all reading it through one parser (tools/tour-doc.mjs), so none can read it differently from another:

Test What it plays Where
npm run tour The shell and Node steps, from the packed tarballs installed in an empty directory; the cells from the notebook’s file store on, run by the packed CLI so the commands see their data tools/tour.mjs
tour-journey.test.ts The whole tour in one timeline: cells on the notebook’s own kernel and the real engine host, commands and the program in a real shell with the real CLI, on the same files. Every answer printed (under a cell, or under a command) must be the one that ran apps/vscode/test/
tour-structure.test.ts The page: every fenced block is a cell, a printed answer or a step (none is only prose); every cell has its answer under it; steps are numbered and referred to by number; every link and anchor resolves; the controls are named as the extension names them; it stays short enough to be five minutes apps/vscode/test/
The VS Code e2e The same journey through a real VS Code, installed from the .vsix: a .tql.md opens as a notebook, the kernel is chosen without the reader choosing it, every cell’s output is what the page prints apps/vscode/e2e/

When the tour or the engine changes on purpose, TOUR_RECORD=1 npx vitest run test/tour-journey.test.ts (from apps/vscode) rewrites the printed answers to what ran. Read the diff: it is the page a reader will see, and a changed answer is a changed experience.

docs/guides/try-it.tql.md is the tour’s TypeQLite half, run in a page (ADR-013). It is played by the same player, in three layers:

Test What it plays Where
try-it-structure.test.ts The page: marked up completely, an answer under every cell, nine cells, no shell step or mention of a command line before “Where next”, byte-exact round trip apps/playground/test/
try-it-journey.test.ts The whole document on the browser’s kernel (createKernel, the host’s operations over a Session) through the shared runner apps/playground/test/
test-browser/notebook.test.ts The same document through the page in Chromium, on WASM SQLite in a worker: every cell run with its play button, Run all, Restart, <img onerror> as text, the language server knowing the cells as one notebook, and no Monaco complaint about semantic tokens apps/playground/test-browser/

TOUR_RECORD=1 npx vitest run test/try-it-journey.test.ts (from apps/playground) rewrites the printed answers.

TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.