Skip to content

Getting Started

Install

Add as-test to an AssemblyScript project:

bash
npm install --save-dev as-test json-as

json-as is a required peer dependency (used for value serialization in assertions, snapshots, and log()). npm 7+ installs it automatically, but pnpm and yarn users must add it explicitly.

If you are upgrading to 1.1.0, refresh generated runners with:

bash
rm -rf .as-test/runners && npx as-test init

Scaffold A Project

The fastest path is the initializer:

bash
npx ast init

Useful variants:

bash
npx ast init --dir .
npx ast init --target wasi
npx ast init --target bindings
npx ast init --target web
npx ast init --fuzz-example
npx ast init --yes

ast init can create:

  • as-test.config.json
  • default runner scripts under .as-test/runners/
  • a sample spec
  • an optional sample fuzzer
  • assembly/tsconfig.json

Run The Suite

Run normal specs:

bash
npx ast test

Run the suite through the ordered file worker pool:

bash
npx ast test --parallel

Run fuzzers only:

bash
npx ast fuzz

Run specs and fuzzers together:

bash
npx ast test --fuzz

Minimal Config

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