# Behavior traces — avajs/ava

> Canonical page: https://codevetter.com/unpack/ava/behavior-traces

# Behavior traces — avajs/ava

Scanned commit bbfd946322fdeca2b547a691d947fb4e18c0c67f (2026-05-17). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Source inspection followed startup, test execution, and snapshot persistence end-to-end, with additional traces for reporting, failures, scheduling, and watch reruns. These are execution-order descriptions from code rather than observed runs. Material conditions include selection, hook failures, CI snapshot policy, and worker shutdown handshakes.
- Startup: entrypoints/cli.js calls loadCli() → loadConfig() → option normalization → new Api() → reporter construction → api.run({filter}); one-shot completion sets process.exitCode and calls reporter.endRun(). — [entrypoints/cli.js#L1-L4](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/entrypoints/cli.js#L1-L4) [lib/cli.js#L95-L105](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/cli.js#L95-L105) [lib/cli.js#L407-L452](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/cli.js#L407-L452) [lib/cli.js#L526-L534](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/cli.js#L526-L534)
- File launch: Api.run() → globs.findTests()/applyTestFileFilter() → scheduler.failingTestsFirst() → provider compile() → pMap() → fork(); serial mode uses one file worker and automatic CI concurrency uses two. — [lib/api.js#L149-L198](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/api.js#L149-L198) [lib/api.js#L240-L258](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/api.js#L240-L258) [lib/api.js#L263-L286](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/api.js#L263-L286)
- Worker bootstrap: run(options) constructs Runner and publishes runnerChain → installs providers → loads setup modules → loads testPath; importing ava marks loadedMain, otherwise the worker reports missing-ava-import and exits. — [lib/worker/base.js#L54-L88](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/base.js#L54-L88) [lib/worker/base.js#L153-L172](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/base.js#L153-L172) [lib/worker/base.js#L207-L238](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/base.js#L207-L238) [lib/worker/main.js#L7-L11](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/main.js#L7-L11)
- Primary test action: chain registration schedules Runner.start() on nextTick → readiness wait → before hooks → serial tests → concurrent tests; runTest() executes beforeEach, Test.run(), success-only afterEach, and afterEach.always. — [lib/runner.js#L87-L98](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L87-L98) [lib/runner.js#L327-L403](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L327-L403) [lib/runner.js#L467-L515](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L467-L515)
- Runnable completion: Test.run() calls the implementation and awaits a returned promise or observable → finish() clears timeout, verifies plan/assertions, awaits reverse-order teardowns, and inverts the result for failing tests. — [lib/test.js#L480-L489](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/test.js#L480-L489) [lib/test.js#L530-L578](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/test.js#L530-L578) [lib/test.js#L599-L646](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/test.js#L599-L646)
- Snapshot persistence: t.snapshot() → Test.compareWithSnapshot() → Runner.compareTestSnapshot() → Manager.compare()/record(); Runner finish triggers saveSnapshotState(), which encodes and atomically writes .snap/.md files before worker-finished. — [lib/assert.js#L650-L672](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/assert.js#L650-L672) [lib/test.js#L221-L238](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/test.js#L221-L238) [lib/runner.js#L216-L225](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L216-L225) [lib/worker/base.js#L102-L122](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/base.js#L102-L122)
- Run closure: workers send worker-finished → parent sends free-worker → worker checks unhandled rejections and schedules completion handlers; parent waits for worker/shared-worker cleanup, stores failed-file state, and ends RunStatus. — [lib/fork.js#L106-L109](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/fork.js#L106-L109) [lib/worker/base.js#L122-L141](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/base.js#L122-L141) [lib/worker/completion-handlers.js#L5-L8](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/worker/completion-handlers.js#L5-L8) [lib/api.js#L301-L315](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/api.js#L301-L315)
- Watch rerun: recursive fs.watch() marks dirty paths → debounce waits for tracing and filters touched files → traceToTestFile() selects dependents or unknown changes trigger all tests → plan() yields options → start() calls Api.run() and ends reporting. — [lib/watcher.js#L159-L171](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/watcher.js#L159-L171) [lib/watcher.js#L426-L443](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/watcher.js#L426-L443) [lib/watcher.js#L529-L585](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/watcher.js#L529-L585) [lib/watcher.js#L721-L744](https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/watcher.js#L721-L744)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
