CodeVetter · Repo Unpack · Behavior traces
avajs/ava
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().
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.