Skip to content

Configuration

Configuration lives in as-test.config.json. The bundled JSON Schema (as-test.config.schema.json) powers editor autocompletion — reference it with $schema:

json
{
  "$schema": "node_modules/as-test/as-test.config.schema.json",
  "input": ["assembly/__tests__/*.spec.ts"],
  "output": ".as-test/",
  "buildOptions": { "target": "wasi" },
  "runOptions": {
    "runtime": { "cmd": "node ./.as-test/runners/default.wasi.js" }
  }
}

Top-level fields

FieldTypeDefaultPurpose
inputstring[]["./assembly/__tests__/*.spec.ts"]Globs for spec files. Negate with !.
outputstring | objectOutput location (alias).
outDirstring./.as-test/buildCompiled artifacts.
logsstring | "none"./.as-test/logsCaptured log() output, or "none".
coverageDirstring | "none"./.as-test/coverageCoverage artifacts, or "none".
snapshotDirstring./.as-test/snapshotsStored snapshots.
coverageboolean | objectfalseCoverage settings.
featuresstring[][]Enabled features.
envstring | string[] | object{}Environment values.
buildOptionsobjectBuild options.
runOptionsobjectRun options.
fuzzobjectFuzz config.
modesobject{}Named modes.
configstring"none"Optional asconfig path passed to asc.

Output paths

output is a convenience alias. Use a single string for the root, or an object to place each artifact kind:

json
{ "output": ".as-test/" }
json
{
  "output": {
    "build": "./.as-test/build",
    "logs": "./.as-test/logs",
    "coverage": "./.as-test/coverage",
    "snapshots": "./.as-test/snapshots"
  }
}

The explicit fields (outDir, logs, coverageDir, snapshotDir) still work and override the alias when both are set. ast clean removes build, logs, and coverage from these locations (and the shared fuzz.crashDir).

Environment values

env, buildOptions.env, and runOptions.env each accept three forms:

  • a .env file path,
  • an array of KEY=value strings,
  • an object map.
json
{ "env": { "LOG_LEVEL": "debug" } }

They merge together — top-level first, then build/run-specific, then mode overrides on top.

Build options

json
{
  "buildOptions": {
    "target": "wasi",
    "args": [],
    "cmd": "",
    "env": {}
  }
}
FieldTypePurpose
target"wasi" | "bindings" | "web"Build target (see Targets & Runtimes).
argsstring[]Extra arguments passed to asc.
cmdstringReplace the default build command entirely.
envenvBuild-only environment overrides.

buildOptions.cmd supports the placeholders <file>, <name>, <outFile>, <target>, and <mode>.

For bindings/web targets, as-test injects --bindings raw unless you declare --bindings yourself in args (or in a referenced asconfig). See Bindings: raw & esm.

Run options

json
{
  "runOptions": {
    "runtime": {
      "cmd": "node ./.as-test/runners/default.wasi.js",
      "browser": ""
    },
    "reporter": "default",
    "env": {}
  }
}
FieldTypePurpose
runtime.cmdstringRuntime command. Supports <file> and <name>.
runtime.browserstringBrowser for web targets: chrome, chromium, firefox, webkit, or a path.
reporterstring | objectReporter selection.
envenvRun-only environment overrides.

The generated runners are env-driven single-file scripts, so standard runner commands don't need a <file> argument. Reporter accepts "", "default", "tap", a custom module path, or an object — see Reporters.

Coverage

Boolean shorthand or a detailed object:

json
{
  "coverage": {
    "enabled": true,
    "mode": "project",
    "dependencies": ["json-as"],
    "includeSpecs": false,
    "include": [],
    "exclude": [],
    "ignore": { "labels": [], "names": [], "locations": [], "snippets": [] }
  }
}
FieldDefaultPurpose
enabledfalseTurn coverage on. "coverage": true is shorthand for { enabled: true, mode: "project" }.
mode"project"project = your sources only; all = include dependencies.
dependencies[]Package-name allowlist for dependency coverage.
includeSpecsfalseInclude *.spec.ts files.
include / exclude[]Glob refinements applied after the above.
ignoreDrop points by labels, names, locations, or snippets.

See Coverage for details.

Fuzz

Used by ast fuzz and ast test --fuzz:

json
{
  "fuzz": {
    "input": ["./assembly/__fuzz__/*.fuzz.ts"],
    "runs": 1000,
    "maxInputBytes": 4096,
    "target": "bindings",
    "corpusDir": "./.as-test/fuzz/corpus",
    "crashDir": "./.as-test/crashes"
  }
}
FieldDefaultPurpose
input["./assembly/__fuzz__/*.fuzz.ts"]Globs for fuzz targets.
runs1000Iterations per target.
seedrandomBase seed; omit for a fresh random seed each run.
maxInputBytes4096Max generated input size.
target"bindings"Fuzz builds require the bindings target.
corpusDir./.as-test/fuzz/corpusSeed corpus.
crashDir./.as-test/crashesCrash artifacts.

Features

features enables compiler-level capabilities:

json
{ "features": ["try-as"] }
  • "try-as" wires up the try-as transform — required for try/catch/finally and the toThrow matcher.
  • Other names (e.g. "simd", "threads") are passed to asc as --enable <name>.

CLI --enable / --disable override the config list. In a mode, features replaces the base list entirely — set "features": [] to disable everything for that mode.

Modes

Modes let one project run against multiple targets or runtime commands. Each entry overrides the base config; a value can be an inline object or a string path to an external config file.

json
{
  "modes": {
    "node:wasi": {
      "buildOptions": { "target": "wasi" },
      "runOptions": { "runtime": { "cmd": "node ./.as-test/runners/default.wasi.js" } }
    },
    "node:bindings": {
      "buildOptions": { "target": "bindings" },
      "runOptions": { "runtime": { "cmd": "node ./.as-test/runners/default.bindings.js" } }
    },
    "chromium:headless": {
      "default": false,
      "buildOptions": { "target": "web" },
      "runOptions": {
        "runtime": {
          "cmd": "node ./.as-test/runners/default.web.js --headless",
          "browser": "chromium"
        }
      }
    }
  }
}

A mode can override input, output directories, coverage, features, fuzz, buildOptions, runOptions, and env.

  • "default": false makes a mode manual-only — skipped on a bare ast test, runnable via --mode.
  • When any modes are declared, an implicit ast test runs only those modes; the unnamed base config is not added on top. With no modes, the base config runs by itself.
  • When multiple modes are active, output paths are namespaced by mode.
  • ast clean cleans every configured mode when --mode is omitted, regardless of default.

See Multiple Runtimes for the conceptual guide.