as-test
as-test is a runtime-aware test runner for AssemblyScript.
You write ordinary specs, snapshots, mocks, and fuzzers once, then run them against the runtime you actually ship to — WASI, Node bindings, the browser, or a standalone runtime like wasmtime — through named modes. Tests are compiled to WebAssembly and executed there, so what you assert is what your users get.
It ships as a CLI (ast / as-test) and an npm dev dependency. There are no required peer dependencies; value formatting for assertions, snapshots, and log() is built in.
What you get
- Specs in
assembly/__tests__/*.spec.tswithdescribe/test/it, lifecycle hooks, and focus/skip/todo. - A full matcher set — deep equality, numeric comparisons, type and truthiness checks, string and collection matchers, snapshots, and
toThrow. - Snapshots stored under
.as-test/and updated from the CLI. - Mocking — swap local functions (
mockFn) or host imports (mockImport) at compile time. - Fuzzing — property tests with deterministic, reproducible seeds in
assembly/__fuzz__/*.fuzz.ts. - Coverage — branch-aware instrumentation with project/dependency filtering.
- Runtimes & modes — one suite, many targets, selected with
--mode. - Reporters — a human-readable default and TAP, plus custom reporter modules.
Start here
- Getting Started — install, scaffold, and run your first suite.
- Writing Tests — suites, hooks, focus/skip, and logging.
- Assertions — the matcher reference.
- Add Snapshots, Mocking, or Fuzzing when you need them.
- Runtimes & Modes — run the same specs across WASI, bindings, and the web.
- CLI and Configuration — once the defaults stop being enough.
Project layout
A typical project looks like this:
text
assembly/
__tests__/
math.spec.ts
__fuzz__/
parser.fuzz.ts
.as-test/
build/ compiled wasm artifacts
runners/ generated runtime entry scripts
logs/ captured log() output
snapshots/ stored snapshots
crashes/ fuzz crash artifacts
as-test.config.jsonIf you also need fast JSON for AssemblyScript data structures, see json-as.
