Skip to content

Conversation

@gnbm
Copy link
Contributor

@gnbm gnbm commented Oct 28, 2025

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Docs have been reviewed and added/updated if needed (for bug fixes/features)
  • Build (npm run build) was run locally, and any changes were pushed
  • Tests (npm test) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe): Testing infrastructure improvements and coverage increase

What is the current behavior?

  • Vitest was upgraded, which revealed a behavior change: vi.restoreAllMocks() no longer clears call history; one test began failing.
  • Some utilities and network-related paths were not fully covered by tests.
  • Overall coverage below 100%, and functions coverage could fail thresholds depending on changes.

GitHub Issue Number: N/A

What is the new behavior?

-Updated test tooling:
- vitest to ^4.0.4
- @vitest/coverage-v8 to ^4.0.4

  • Stabilized tests for Vitest v4:

    • Added vi.clearAllMocks() in src/git.test.ts to isolate call history per test
  • Extended test coverage:

    • Added src/download.mocked.test.ts to cover proxy agent usage, HEAD method for existence checks, and string URL handling without real network calls
    • Added tests in src/utils.test.ts:
      • Covered both branches of setTmpDirectory and validated registered process handlers (exit codes)
      • Exercised nodeVersionWarning edge cases, including the fallback when version parts are empty
      • Added a direct test for killChildren using fresh module state
      • Renamed onlyUnix tests for clarity (Windows returns string; Unix returns empty string)
  • All tests passing locally

  • Coverage:

    • 100% statements, branches, functions, and lines across the project

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • Local runs (Windows):
    • npm ci
    • npm test -- --run
    • Verified output shows all suites passing and full coverage:
      • Test Files: 6 passed
      • Tests: 54 passed
      • Coverage (V8): 100% across statements, branches, functions, lines
  • Verified that no real network calls are made in mocked download tests
  • Verified watch mode stability in Vitest v4

Other information

  • New test file: src/download.mocked.test.ts
  • Minor naming tweaks to improve test intent clarity in src/utils.test.ts
  • This PR does not change runtime CLI behavior; it only improves testing accuracy, isolation, and coverage with the upgraded test runner.

@gnbm gnbm added the dependencies Pull requests that update a dependency file label Oct 28, 2025
@gnbm gnbm marked this pull request as ready for review October 29, 2025 00:03
@gnbm gnbm requested a review from a team as a code owner October 29, 2025 00:03
@gnbm gnbm merged commit 85de932 into main Oct 29, 2025
11 checks passed
@gnbm gnbm deleted the upgrade-vitest-increase-test-coverage branch October 29, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants