ワンクリックで
stack-l3-vitest
Vitest testing framework API reference, patterns, and harness-specific testing conventions
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Vitest testing framework API reference, patterns, and harness-specific testing conventions
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when detecting and guardrailing against premature completion claims — verifying that subagent "done" assertions are backed by fresh runtime evidence, enforcing dual-signal completion protocol (doer + verifier must agree), and catching hollow "it works" claims that skip verification. Triggers on: "verify completion", "completion detection", "dual-signal", "premature completion", "evidence before claims", "hollow done", "fake done", "completion guardrail", "verify before complete", "block completion until verified", "done but not verified", "did it actually work", "completion verification", "dual-signal completion", "two-agent completion", "fresh evidence requirement". NOT for loop mechanics (iterative-loop), delegation patterns (subagent-delegation-patterns), or quality gate triad orchestration (quality-gate-orchestration).
Use when making cross-cutting changes, cross-pane modifications, framework migrations, or breaking changes that span multiple layers or frameworks (GSD, BMAD, Hivemind, or other). Triggers on: "cross-cutting change", "cross-pane change", "multi-layer change", "framework migration", "breaking change across frameworks", "change impact analysis", "cross-framework change", "multi-pane impact", "test-first change ordering", "dependency ordering across layers", "consumer impact tracing", "interface-first change", "ordered change management". NOT for single-layer changes, single-framework refactors, or cosmetic edits. Framework-agnostic — works across GSD, BMAD, Hivemind, or any project governance framework.
Evaluates whether implementation evidence is sufficient to pass quality gates. Enforces an evidence hierarchy from live runtime proof (L1) down to documentation summaries (L5), and refuses gate passage when evidence is missing, mocked where integration is claimed, or insufficient for the gate type. Use during code review gates, phase audits, milestone verification, integration checks, and deployment readiness. Activates after gate-spec-compliance clears spec alignment — this is the terminal gate in the triad (lifecycle → spec → evidence). Triggers: "evidence check", "gate evidence", "verify runtime proof", "evidence truth", "is there proof this works", "evidence hierarchy", "gate truth", "runtime evidence", "integration evidence", "mock-only detection", "completion honesty", "gate passed", "gate failed". Terminal skill in the quality gate triad — if evidence PASSES, all 3 gates clear.
Internal quality gate that evaluates whether Hivemind harness implementations correctly participate in the runtime lifecycle — covering 9-surface mutation authority, CQRS boundaries, actor hierarchy, event-driven wiring, classification fit (src/ vs .opencode/ vs .hivemind/), and OpenCode SDK surface compliance. Synthesized from .planning/codebase/ARCHITECTURE.md (9-surface authority table) and ingested @opencode-ai/plugin SDK v1.14.44 from anomalyco/opencode (tool(), hook() signatures). Use when performing a lifecycle gate check, auditing harness module integration, verifying CQRS boundary compliance, checking delegation hierarchy constraints, evaluating tool/hook registration correctness, running a harness quality gate, validating plugin composition integrity, or running phase audit on src/ modules. Activates during code review of src/ files, phase audit, milestone verification, integration check, and deployment readiness workflows.
Spec compliance gate performing bidirectional traceability, gap detection (4 types), EARS acceptance criteria validation, and anti-pattern scanning. Use during code review gates, phase audits, milestone verification, and deployment readiness. Middle gate in the quality triad (lifecycle → spec → evidence). Routes to gate-evidence-truth on PASS; STOPS with gap report on FAIL. Includes remediation routing to hm-spec-driven-authoring, hm-test-driven-execution, and hm-debug for fix workflows. Triggers on: "spec compliance", "verify against spec", "gap analysis", "compliance gate", "phase audit gate", "acceptance criteria check", "spec-to-code", "deployment readiness", "triad gate", "spec gate middle", "quality triad".
Detects and fixes drift between AGENTS.md documentation and actual codebase state. Scans source files and .opencode/ directories, compares claims against reality, produces a structured drift report, then applies targeted edits. Triggers on: 'sync agents md', 'update AGENTS.md', 'fix agents md drift', 'AGENTS.md out of date', 'check agent instruction drift'. NOT for generic documentation writing or README refreshes.
| name | stack-l3-vitest |
| version | 4.1.0 |
| description | Vitest testing framework API reference, patterns, and harness-specific testing conventions |
| category | stack |
| triggers | ["vitest","test","describe","expect","vi.mock","vi.fn","coverage","unit test","integration test","mock","spy","benchmark","snapshot","fixture","beforeEach","afterEach","beforeAll","afterAll","vitest.config","test.extend"] |
| metadata | {"layer":"3","role":"reference","lineage":"stack"} |
Vitest 4.x — Next-generation testing framework powered by Vite.
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
| Topic | File | What You'll Find |
|---|---|---|
| Assertions | references/api/assertions.md | expect() + all matchers |
| Mocking & Spying | references/api/mocking.md | vi.mock, vi.fn, vi.spyOn, timers, globals |
| Lifecycle | references/api/lifecycle.md | describe, it, test, hooks, modifiers |
| Configuration | references/api/configuration.md | vitest.config.ts options |
| Coverage | references/api/coverage.md | V8/Istanbul providers, thresholds, reports |
| Testing Patterns | references/patterns/testing.md | Harness-specific test structures |
| Mocking Patterns | references/patterns/mocking.md | SDK, delegation, continuity mocking |
| TOC | TOC.md | Full table of contents |
globals: true in configjest.fn() → vi.fn()v8 (fast, native) or istanbul (instrumented)aroundEach/aroundAll hooks, test.describe/test.suite, toMatchScreenshot()npx vitest # Watch mode
npx vitest run # Single run (CI)
npx vitest run --coverage # With coverage
npx vitest run -t "pattern" # Run matching tests
npx vitest --ui # Browser UI
npx vitest bench # Run benchmarks
// vitest.config.ts — this project uses:
// - vitest globals: true (no imports needed)
// - coverage provider: v8
// - test location: tests/lib/**, tests/tools/**
// - src coverage: src/**/*.ts (excludes index.ts)
| When working on... | Also load... | Because... |
|---|---|---|
| Testing OpenCode plugin tools | stack-opencode | ToolContext mock setup, ToolResult shape |
| Testing Zod schemas | stack-zod | Schema validation edge cases, v4 migration |
| Test-driven development workflow | hm-test-driven-execution | RED/GREEN/REFACTOR cycle patterns |
| Next.js component testing | stack-nextjs | Server component mocking, route handler testing |
Stack reference for Vitest 4.x. See TOC.md for full navigation.
ABSOLUTE RULE: No bundled reference, cached asset, or stale pattern from this skill shall be consumed for tech-stack API interface decisions without MCP-verified validation against the project's ACTUAL versions (package.json + lockfile), canonical source mappings (
.hivemind/STACKS-REFERENCES.md), AND a raw codebase context scan of the current implementation state.
Skills bundle references and assets as ORIENTATION tools — they help you understand WHAT exists and WHERE to look. But every bundled reference is a SNAPSHOT, frozen at the moment of ingestion. Stacks evolve: packages release breaking changes, APIs shift, SDKs deprecate surfaces. Using stale bundled signatures as implementation authority produces silent runtime errors.
Before ANY tech-stack API interface from this skill's references/assets is used for implementation, code generation, or quality gate decisions:
STEP 1 — CONSUME .hivemind/STACKS-REFERENCES.md
├─ Read the canonical stack→repo→version mapping table
├─ Identify the correct GitHub repo for each dependency
└─ Confirm the repo is active (not archived), version is current
STEP 2 — READ package.json + lockfile
├─ Extract the ACTUAL installed version (npm ls / grep lockfile)
├─ Cross-reference repo URL from STACKS-REFERENCES.md against npm registry
└─ Flag any discrepancy between bundled version and installed version
STEP 3 — RAW CODEBASE CONTEXT SCAN
├─ grep/glob the actual src/ directory structure for current implementation
├─ Read current implementation files — not stale docs or bundled references
├─ Verify the claimed API signatures match current codebase reality
└─ Check import paths, type definitions, and function signatures exist in actual code
STEP 4 — MCP LIVE VALIDATION (minimum 2 tools)
├─ Context7: resolve-library-id → query-docs (API signatures at installed version)
├─ DeepWiki: ask-question (architecture patterns, behavioral semantics)
├─ Repomix: pack-remote-repository (full repo analysis at correct version tag)
├─ Exa: web-search (latest docs, tutorials, migration guides)
├─ Tavily: search + extract (version-specific migration info)
├─ GitHub: get-file-contents (exact source verification at correct version)
└─ GitMCP: search-code (source-level pattern matching)
STEP 5 — VERIFICATION RECORD
├─ Source URL + version confirmed to match package.json
├─ MCP tool(s) used + fetch timestamp
├─ Codebase scan paths + findings
├─ Version match status (MATCHED / MISMATCHED / UNVERIFIED)
└─ Flag as BLOCKING if version mismatch or critical staleness detected
| Action | Rule |
|---|---|
| Orientation (understanding WHAT exists, WHERE to look) | ✅ Reference-tier allowed from bundled assets without live validation |
| API signature lookup for implementation | 🚫 BLOCKED without live MCP validation (Step 4) + codebase scan (Step 3) |
| Interface verification for quality gates | 🚫 BLOCKED without live MCP validation (Step 4) + version match (Step 2) |
| Version-sensitive behavioral claims | 🚫 BLOCKED without live MCP validation (Step 4) |
| Architecture pattern understanding | ✅ Reference-tier allowed, but recommend live verification for production decisions |
| Generating code from bundled patterns | 🚫 BLOCKED — route to live MCP tools for current API surface |
| Workflow Phase | IRON CLAW Trigger | Required Validation |
|---|---|---|
| Implementation | Before using any API from bundled refs | Steps 2-4 minimum |
| Code review | When verifying API usage against docs | Steps 2-4 minimum |
| Quality gate | Before PASS verdict on interface claims | Steps 1-5 full |
| Research | When synthesizing findings from cached assets | Steps 4-5 minimum |
| Audit | When reporting version-based findings | Steps 1-5 full |
Reference documents provide facts, not workflows. When facts conflict with reality, this section guides resolution.
npx --yes ctx7 library vitest "migration guide".npx vitest --version for the project's Vitest version.aroundEach/aroundAll, test.describe, toMatchScreenshot()) may have evolved since this reference — check the Vitest changelog if behavior differs.npx vitest --api for CLI options, or check TypeScript definitions via node_modules/vitest/dist/index.d.ts.references/api/assertions.md, references/api/mocking.md) — extracted from 4.1.0 behavior.vitest.config.ts has been modified, the reference may not reflect current configuration.vitest.config.ts and installed version have final authority.test.extend fixture patterns.references/patterns/testing.md, references/patterns/mocking.md) — project-specific patterns may cover common edge cases.vitest-dev/vitest for known bugs and workarounds.