Skip to content

feat: add vitest test runner with fixture loader and mock activation#260

Merged
snipcodeit merged 1 commit intomainfrom
issue/249-add-vitest-test-runner-with-fixture-load
Mar 6, 2026
Merged

feat: add vitest test runner with fixture loader and mock activation#260
snipcodeit merged 1 commit intomainfrom
issue/249-add-vitest-test-runner-with-fixture-load

Conversation

@snipcodeit
Copy link
Owner

Summary

Closes #249

Configures vitest as the test runner for the v6 Local Testing & Simulation Framework (Phase 47: Mock Infrastructure). Adds test/setup.js for automatic mock activation, a loadFixture(name) helper, and vitest-based npm scripts.

Phase Context: Phase 47 of 4 in milestone v6 — Local Testing & Simulation Framework
GSD Route: plan-phase (quick-full execution)

Changes

File Change
package.json Add vitest ^2.0.0 devDependency; npm testvitest run; new test:watch and test:node scripts
vitest.config.js New — node environment, setupFiles, include .test.js, exclude .test.cjs
test/setup.js New — conditional mock activation via beforeEach/afterEach; exports mockGitHub/mockGsdAgent
test/loadFixture.js New — loadFixture(name) reads from test/fixtures/; namespaced paths supported

Mock Compatibility

test/setup.js uses conditional require() with try/catch for both lib/mock-github.cjs (PR #258) and lib/mock-gsd-agent.cjs (PR #259). The vitest infrastructure is fully functional before those PRs merge — tests run without errors and mocks auto-activate once the dependencies land.

Script Compatibility

Existing node:test based *.test.cjs files are preserved and accessible via npm run test:node. The vitest include pattern targets .test.js and .spec.js only, with .test.cjs explicitly excluded.

Plan Summary (quick-10)

Task 1: Add vitest devDependency and update npm scripts in package.json
Task 2: Create vitest.config.js with setupFiles, node environment, include/exclude patterns
Task 3: Create test/setup.js with conditional mock activation (beforeEach/afterEach)
Task 4: Create test/loadFixture.js with loadFixture(name) helper and FIXTURES_DIR export

All 4 tasks completed in commit 0ef8314.

Test Plan

Dependencies

🤖 Generated with Claude Code

Configures vitest as the primary test runner for the v6 Local Testing
& Simulation Framework (Phase 47: Mock Infrastructure, issue #249).

Changes:
- package.json: add vitest ^2.0.0 devDependency; npm test → vitest run;
  npm run test:watch → vitest; npm run test:node preserves existing
  node --test runner for .test.cjs files
- vitest.config.js: node environment, setupFiles: ['./test/setup.js'],
  includes .test.js/.spec.js, excludes .test.cjs (node:test incompatible)
- test/setup.js: auto-activates mock-github and mock-gsd-agent in
  beforeEach/afterEach; conditional require — works when PRs #258/#259
  are not yet merged to main; exports mockGitHub/mockGsdAgent
- test/loadFixture.js: loadFixture(name) helper that reads from
  test/fixtures/; supports namespaced paths (e.g. 'github/issue-view');
  throws descriptive errors on missing/invalid fixtures

Closes #249

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
snipcodeit pushed a commit that referenced this pull request Mar 6, 2026
…cycle (#250)

Adds test/validate-and-load.test.js with 23 vitest integration tests (5 groups)
covering fresh .mgw/ init, migrateProjectState() idempotency, loadActiveIssue()
prefix pattern, staleness detection via mock-github.cjs, and loadCrossRefs()
validation — all isolated in tmp directories via process.cwd() override.

Also includes vitest infrastructure (vitest.config.js, test/setup.js,
test/loadFixture.js, test/fixtures/github/) from PRs #247 and #260 required
to run the test suite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@snipcodeit snipcodeit merged commit b46942c into main Mar 6, 2026
1 of 5 checks passed
@snipcodeit snipcodeit deleted the issue/249-add-vitest-test-runner-with-fixture-load branch March 6, 2026 11:18
snipcodeit pushed a commit that referenced this pull request Mar 6, 2026
…cycle (#250)

Adds test/validate-and-load.test.js with 23 vitest integration tests (5 groups)
covering fresh .mgw/ init, migrateProjectState() idempotency, loadActiveIssue()
prefix pattern, staleness detection via mock-github.cjs, and loadCrossRefs()
validation — all isolated in tmp directories via process.cwd() override.

Also includes vitest infrastructure (vitest.config.js, test/setup.js,
test/loadFixture.js, test/fixtures/github/) from PRs #247 and #260 required
to run the test suite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
snipcodeit added a commit that referenced this pull request Mar 6, 2026
…cycle (#250) (#261)

Adds test/validate-and-load.test.js with 23 vitest integration tests (5 groups)
covering fresh .mgw/ init, migrateProjectState() idempotency, loadActiveIssue()
prefix pattern, staleness detection via mock-github.cjs, and loadCrossRefs()
validation — all isolated in tmp directories via process.cwd() override.

Also includes vitest infrastructure (vitest.config.js, test/setup.js,
test/loadFixture.js, test/fixtures/github/) from PRs #247 and #260 required
to run the test suite.

Co-authored-by: Stephen Miller <Stephen@betterbox.pw>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add vitest test runner with fixture loader and mock activation

1 participant