Skip to content

Conversation

@TabishB
Copy link
Contributor

@TabishB TabishB commented Sep 6, 2025

Summary

  • Fixed test failures caused by missing dist/ directory when tests spawn CLI subprocesses
  • Implemented proper build setup using Vitest's globalSetup instead of per-test builds
  • Removed CI workflow complexity - simplified to single Node version for faster runs

Problem

Tests were failing with ERR_MODULE_NOT_FOUND because:

  1. Tests that use execSync to run the CLI binary require the dist/ directory
  2. The build wasn't completing reliably before tests ran
  3. Race conditions occurred when tests ran in parallel

Solution

Phase 1: Initial fix (commit 6e210cf)

  • Created ensureBuild() helper to check and build if needed
  • Updated 8 test files to ensure build before spawning CLI

Phase 2: Proper solution (commit 57216a7)

  • Moved build logic to vitest.setup.ts using Vitest's globalSetup
  • Removed per-test build logic for cleaner separation of concerns
  • Single build check instead of multiple redundant checks

Changes

  1. Added vitest.setup.ts: Global setup that builds project once before all tests
  2. Updated vitest.config.ts: Configured to use globalSetup
  3. Cleaned test files: Removed all beforeAll build blocks and unused imports
  4. Simplified CI: Using single Node 20 version for faster CI runs

Benefits

  • ✅ Tests no longer manage builds (proper separation of concerns)
  • ✅ Better performance (one build check vs many)
  • ✅ Cleaner test code
  • ✅ Proper error handling with clear messages
  • ✅ CI-friendly solution

Test Results

All 148 tests passing locally and in CI.

🤖 Generated with Claude Code

@TabishB TabishB merged commit 02fe5b3 into main Sep 6, 2025
4 checks passed
drvova pushed a commit to drvova/VovaSpec that referenced this pull request Oct 13, 2025
fix(test): resolve CI test failures with proper build setup
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.

2 participants