/** * `peaks test ` — slice 2.5.0 sub-fix B (Prob 2). * * Wraps the consumer project's test framework (jest / vitest / mocha) * with a per-test fingerprint cache. The wrapper: * * 1. Auto-detects the framework from package.json (devDependencies + * dependencies) via detectTestFramework(). * 2. Resolves the project-LOCAL runner binary (node_modules) and spawns * that, so the command works where the runner is not on PATH — notably * Windows, where node_modules/.bin/vitest.cmd is not spawnable without * a shell. PATH is a last resort and is reported, not silent. * 3. Spawns the framework's CLI with --cache enabled (overriding any * --no-cache in the consumer's `test` script). The user can * opt back into no-cache via `peaks test --no-cache` or * `peaks test --passthrough`. * 4. Skips tests where (fileMtime, fileSha256) is unchanged AND the * previous run status was 'passed' (per-test fingerprint cache at * `/.peaks/_runtime/test-cache/.json`). * 5. Exits 0 on all-pass / all-skip; exits 1 on any failure. * * The CLI is invoked by USER (not just by skill) per slice 2.5.0 * sub-fix B (G16) — a documented exception to the * dev-preference red-line "no new top-level peaks ". * * Sub-commands: * peaks test — run tests matching the pattern * peaks test --all — run the full suite * peaks test --changed — only files changed since HEAD * peaks test --clear-cache — empty the fingerprint cache * peaks test --no-cache-result — bypass the fingerprint cache * peaks test --no-cache — pass --no-cache to the framework * peaks test --passthrough — do NOT override the consumer's argv * peaks test --framework — force a specific framework * * The runner resolution and this file's spawn site live here; the action body * it dispatches to lives in `test-command-run.ts` and the argv/probe rules in * `test-command-runner-resolution.ts`. */ import { spawn } from 'node:child_process'; import type { Command } from 'commander'; import { type ProgramIO } from '../cli-helpers.js'; import type { TestFramework } from '../../services/test-cache/test-cache-service.js'; import { type ResolveRunnerDeps } from './test-command-runner-resolution.js'; export type RunRunnerDeps = ResolveRunnerDeps & { spawnFn?: typeof spawn; }; export declare function runRunner(framework: TestFramework, argv: string[], projectRoot: string, deps?: RunRunnerDeps): Promise<{ code: number; stdout: string; stderr: string; notice: string | null; }>; export declare function registerTestCommands(program: Command, _io: ProgramIO): void; export { buildRunnerArgv, formatRunnerNotFound, resolveRunner, type ResolveRunnerDeps, type RunnerFound, type RunnerResolution } from './test-command-runner-resolution.js'; export type { TestOptions } from './test-command-run-helpers.js';