Targets & Runtimes
as-test compiles each spec to WebAssembly and runs it on a real runtime. The target decides how the wasm is built; the runtime decides what executes it. You pick the target in buildOptions.target and the runtime in runOptions.runtime.cmd.
| Target | Built for | Default runner |
|---|---|---|
wasi | WASI runtimes (Node's WASI, or standalone engines) | .as-test/runners/default.wasi.js |
bindings | a JavaScript host (Node/Bun) | .as-test/runners/default.bindings.js |
web | a browser | .as-test/runners/default.web.js |
The runner scripts are generated by ast init and are thin: they call instantiate() from as-test/lib, which wires up host I/O and the WIPC channel the CLI uses to collect results.
WASI
The wasi target builds against @assemblyscript/wasi-shim and runs on any WASI preview1 runtime. The default runner uses Node's built-in WASI. The same artifact also runs on standalone engines — see Multiple Runtimes for wasmtime / wasmer / wazero modes.
{
"buildOptions": { "target": "wasi" },
"runOptions": { "runtime": { "cmd": "node ./.as-test/runners/default.wasi.js" } }
}WASI is the default target and the most portable. Host I/O (including the result channel) goes through standard WASI file descriptors, so nothing extra needs to be injected at instantiation — which is why WASI can run on engines as-test doesn't control.
Bindings
The bindings target produces a JavaScript host (Node or Bun) plus an AssemblyScript bindings helper. This is the target to choose when your code calls @external host functions you implement in JS. Bindings come in two flavors, raw and esm, with different capabilities — see Bindings: raw & esm.
{
"buildOptions": { "target": "bindings" },
"runOptions": { "runtime": { "cmd": "node ./.as-test/runners/default.bindings.js" } }
}Web
The web target runs specs in a real browser. The runner serves the wasm and helper, drives the browser, and streams results back. Choose the browser with runtime.browser (or --browser), and add --headless for CI.
{
"buildOptions": { "target": "web" },
"runOptions": {
"runtime": {
"cmd": "node ./.as-test/runners/default.web.js --headless",
"browser": "chromium"
}
}
}Supported browsers: chrome, chromium, firefox, webkit, or a path to an executable.
Choosing a target
- Default to
wasi— most portable, runs anywhere, no host glue. - Use
bindingswhen specs depend on JS-provided@externalimports, or when you ship to a JS host. - Use
webto validate browser-specific behavior.
You don't have to choose just one. Multiple Runtimes shows how to run the same specs across several targets in a single command.
