Skip to content

Releases: craigvandotcom/vitest-affected

v0.4.1 — Windows path fixes and hygiene

25 Feb 11:27

Choose a tag to compare

Fixed

  • Windows path normalization — all file paths (git output, oxc-resolver output, changedFiles option, glob results) now consistently use forward slashes matching Vite convention. Previously, path.sep mismatches caused silent BFS failures on Windows, making every run fall back to full suite.
  • isUnderRootDir cache miss on Windows — used path.sep but stored paths use /, causing every cache load to be a miss
  • CONFIG_BASENAMES missing .cts/.cjs variants — changing vitest.config.cts or vite.config.cjs would not trigger full-suite safety fallback
  • setupFiles relative path comparison — relative setupFile paths from Vitest now resolved to absolute before comparison, preventing silent bypass of full-suite trigger
  • writeStatsLine silent failures — now logs errors in verbose mode instead of swallowing all failures

Install

npm install -D vitest-affected@0.4.1

v0.4.0 — Runtime-first architecture

25 Feb 11:01

Choose a tag to compare

What's New

Runtime-First Architecture

Replaced the static analysis pipeline (~1,500 lines) with runtime importDurations from Vitest. First run executes the full suite and caches the reverse dependency map; subsequent runs load the cache, delta-parse only changed files (~5ms), and BFS-select affected tests.

  • v2 cache format ({ version: 2, builtAt, reverseMap }) with automatic v1 migration
  • builder.ts reduced from ~253 to ~133 lines
  • cache.ts reduced from ~834 to ~210 lines
  • plugin.ts rewritten around configureVitest hook with runtime reporter injection
  • Net reduction: -2,969 lines across source and tests

Bug Fixes

  • Cache overwrite on selective runs — was replacing entire cache with edges from only the tests that ran, now uses per-test merge strategy
  • Stale edge pruning — cache was grow-only, now prunes edges for tests that ran before re-adding fresh ones
  • testModule.moduleId normalization — un-normalized paths with query strings failed lookup
  • Cross-platform path handling fixes (Windows compat, Vite / vs path.sep)
  • saveCacheSync temp file cleanup on renameSync failure

Removed

  • buildFullGraph, buildFullGraphSync, and all v1-only cache functions
  • 4 obsolete v1 test files

Install

npm install -D vitest-affected

See README for setup instructions.

v0.3.0

24 Feb 14:04

Choose a tag to compare

What's New

Dependency Graph Caching (Phase 2)

  • Graph persists to .vitest-affected/graph.json with mtime-based staleness detection
  • Only changed files are re-parsed on subsequent runs — cold-start graph building is a one-time cost
  • New file discovery on incremental loads via glob pass
  • Schema validation, path confinement, and stale entry pruning for cache integrity

Watch Mode + Runtime Edges (Phase 3)

  • Runtime reporter captures actual module imports during test execution
  • Runtime edges are merged into the static graph for more accurate watch-cycle filtering
  • Handles cases where static analysis can't resolve dynamic imports

Security & Correctness Fixes

  • Fix normalizeModuleId off-by-one (/@fs/ is 5 chars, not 4)
  • Add prototype pollution protection via safeJsonReviver on all JSON.parse sites
  • Add forward-graph guard in runtime reporter callback
  • Validate and prune runtimeEdges from existing cache before merging

Dogfooding

Successfully tested on a 2,863-test Next.js project (body-compass-app). With changedFiles pointing at a single utility file, the plugin selected 3 test files (22 tests) out of 162 test files — a 98% reduction in tests run.

Install

npm install -D vitest-affected

See README for setup instructions.