Skip to content

chore: upgrade vitest to v4 (coordinated with @vitest/coverage-v8 v4) - #1352

Merged
tamirdresher merged 4 commits into
github:devfrom
tamirdresher:tamirdresher/vitest-4-upgrade
Jun 16, 2026
Merged

tamirdresher merged 4 commits into
github:devfrom
tamirdresher:tamirdresher/vitest-4-upgrade

Conversation

@tamirdresher

Copy link
Copy Markdown
Collaborator

chore: bump vitest from v3 to v4 (coordinated with @vitest/coverage-v8 v4)

Closes #1337

Problem

Dependabot #1337 bumped @vitest/coverage-v8 from 3.2.4 to 4.1.9 but left vitest at ^3.0.0, producing a peer-dependency conflict in CI:

npm error code ERESOLVE
npm error While resolving: @vitest/coverage-v8@4.1.9
npm error Found: vitest@3.2.4
npm error peer vitest@"4.1.9" from @vitest/coverage-v8@4.1.9

Fix

Bump vitest to ^4.1.9 in all packages that referenced ^3.0.0:

  • package.json (root workspace)
  • samples/autonomous-pipeline/package.json
  • samples/cost-aware-router/package.json
  • samples/hello-squad/package.json
  • samples/hook-governance/package.json

(samples/streaming-chat was already at ^4.1.9.)

Vitest v4 API adaptations

Two test files required surgical fixes for vitest 4 behavioural changes:

test/cli/loop.test.ts — vi.clearAllMocks() added to afterEach
Vitest 4's spying rewrite no longer resets vi.fn() call histories when vi.restoreAllMocks() is called. The test skips gh copilot preflight when agentCmd is provided was seeing stale execFile call counts carried over from the preceding test.

test/cli/watch-capabilities.test.ts — constructor mock changed to use function keyword
vi.fn(() => mockStorage) fails with TypeError: () => mockStorage is not a constructor in vitest 4 because arrow functions cannot be invoked with new. Changed to vi.fn(function() { return mockStorage; }).

Testing

  • npm run build ✅
  • npm run lint ✅
  • npx vitest run test/cli/ test/integration.test.ts — 542 passed, 2 failed (both Windows-known flakes: state-mcp.test.ts timeout, team-root-resolution.test.ts path issue)

dependabot Bot and others added 2 commits June 16, 2026 09:13
Bumps [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8) from 3.2.4 to 4.1.9.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Changelog](https://github.com/vitest-dev/vitest/blob/main/docs/releases.md)
- [Commits](https://github.com/vitest-dev/vitest/commits/v4.1.9/packages/coverage-v8)

---
updated-dependencies:
- dependency-name: "@vitest/coverage-v8"
  dependency-version: 4.1.9
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…itest/coverage-v8 v4

Dependabot github#1337 bumped @vitest/coverage-v8 to ^4.1.9 but left vitest at
^3.0.0, causing ERESOLVE in CI. This commit aligns both packages at ^4.1.9
across root and all sample workspaces that referenced ^3.0.0.

Vitest v4 API adaptations required:
- test/cli/loop.test.ts: add vi.clearAllMocks() to afterEach — vitest 4
  no longer resets vi.fn() call history on vi.restoreAllMocks(); the
  'skips gh copilot preflight when agentCmd is provided' test was seeing
  stale execFile call counts from the prior test.
- test/cli/watch-capabilities.test.ts: FSStorageProvider mock changed from
  vi.fn(() => mockStorage) to vi.fn(function() { return mockStorage; }) —
  vitest 4 spying rewrite requires 'function' keyword (not arrow function)
  for mocks used as constructors with 'new'.

No changes to non-test, non-package-version code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 09:31
@github-actions

github-actions Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #1352

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 14
Files added 1
Files modified 13
Files deleted 0
Modules touched 2
Critical files 5

🎯 Risk Factors

  • 14 files changed (6-20 → MEDIUM)
  • 2 modules touched (2-4 → MEDIUM)
  • Critical files touched: package.json, samples/autonomous-pipeline/package.json, samples/cost-aware-router/package.json, samples/hello-squad/package.json, samples/hook-governance/package.json

📦 Modules Affected

root (7 files)
  • .changeset/vitest-4-upgrade.md
  • package-lock.json
  • package.json
  • samples/autonomous-pipeline/package.json
  • samples/cost-aware-router/package.json
  • samples/hello-squad/package.json
  • samples/hook-governance/package.json
tests (7 files)
  • test/adapter-client.test.ts
  • test/cli/loop.test.ts
  • test/cli/watch-capabilities.test.ts
  • test/client.test.ts
  • test/integration.test.ts
  • test/session-traces.test.ts
  • test/state/squad-state-gaps.test.ts

⚠️ Critical Files

  • package.json
  • samples/autonomous-pipeline/package.json
  • samples/cost-aware-router/package.json
  • samples/hello-squad/package.json
  • samples/hook-governance/package.json

This report is generated automatically for every PR. See #733 for details.

@github-actions

github-actions Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

🔒 Security Review

🔒 Security review: 5 info.

Severity Category Finding Location
ℹ️ info new-dependency 2 new/changed dependency version(s) in package.json. Verify these packages are trusted and necessary. package.json:40
ℹ️ info new-dependency 1 new/changed dependency version(s) in samples/autonomous-pipeline/package.json. Verify these packages are trusted and necessary. samples/autonomous-pipeline/package.json:19
ℹ️ info new-dependency 1 new/changed dependency version(s) in samples/cost-aware-router/package.json. Verify these packages are trusted and necessary. samples/cost-aware-router/package.json:18
ℹ️ info new-dependency 1 new/changed dependency version(s) in samples/hello-squad/package.json. Verify these packages are trusted and necessary. samples/hello-squad/package.json:16
ℹ️ info new-dependency 1 new/changed dependency version(s) in samples/hook-governance/package.json. Verify these packages are trusted and necessary. samples/hook-governance/package.json:16

Automated security review — informational only.

@github-actions

github-actions Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 2d03d3c

PR Scope: 🔧 Infrastructure

⚠️ 4 item(s) to address before review

Status Check Details
❌ Single commit 4 commits — consider squashing before review
✅ Not in draft Ready for review
✅ Branch up to date Up to date with dev
❌ Copilot review No Copilot review yet — it may still be processing
✅ Changeset present Changeset file found
✅ Scope clean No .squad/ or docs/proposals/ files
✅ No merge conflicts No merge conflicts
❌ Copilot threads resolved 6 unresolved Copilot thread(s) — fix and resolve before merging
❌ CI passing 7 check(s) still running

Files Changed (14 files, +750 −1324)

File +/−
.changeset/vitest-4-upgrade.md +6 −0
package-lock.json +710 −1291
package.json +2 −2
samples/autonomous-pipeline/package.json +1 −1
samples/cost-aware-router/package.json +1 −1
samples/hello-squad/package.json +1 −1
samples/hook-governance/package.json +1 −1
test/adapter-client.test.ts +3 −3
test/cli/loop.test.ts +1 −0
test/cli/watch-capabilities.test.ts +1 −1
test/client.test.ts +17 −15
test/integration.test.ts +3 −3
test/session-traces.test.ts +3 −3
test/state/squad-state-gaps.test.ts +0 −2

Total: +750 −1324


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the repo’s test toolchain from Vitest v3 to Vitest v4 (coordinated with @vitest/coverage-v8 v4) to resolve a CI peer-dependency conflict introduced by a prior dependency bump.

Changes:

  • Bump vitest and @vitest/coverage-v8 to ^4.1.9 in the root devDependencies and bump vitest to ^4.1.9 in several sample package.json files.
  • Apply small Vitest v4 compatibility tweaks in CLI tests (vi.clearAllMocks() in afterEach, and a constructor-safe mock for FSStorageProvider).
  • Add a changeset documenting the upgrade.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
package.json Updates root devDependencies to Vitest v4 / coverage v4.
package-lock.json Refreshes lockfile to the Vitest v4 dependency graph (including updated transitive deps like Vite).
samples/autonomous-pipeline/package.json Bumps sample devDependency vitest to v4.
samples/cost-aware-router/package.json Bumps sample devDependency vitest to v4.
samples/hello-squad/package.json Bumps sample devDependency vitest to v4.
samples/hook-governance/package.json Bumps sample devDependency vitest to v4.
test/cli/loop.test.ts Clears mock call history between tests to match Vitest v4 behavior.
test/cli/watch-capabilities.test.ts Updates a mock to be constructible under Vitest v4.
.changeset/vitest-4-upgrade.md Adds release notes for the upgrade (needs wording adjustment per review).

"@bradygaster/squad-cli": patch
---

Bump vitest from v3 to v4 alongside @vitest/coverage-v8 v4 to resolve peer-dep mismatch. Both packages now align at ^4.1.9 across root and all sample workspaces. No API adaptations required — vitest 4's spying rewrite is backwards-compatible for the mock/spyOn patterns used in this codebase.
Comment on lines 17 to 20
"devDependencies": {
"typescript": "^5.7.0",
"vitest": "^3.0.0"
"vitest": "^4.1.9"
},
Comment on lines 16 to 19
"devDependencies": {
"typescript": "^5.7.0",
"vitest": "^3.0.0"
"vitest": "^4.1.9"
},
Comment on lines 14 to 18
"devDependencies": {
"tsx": "^4.0.0",
"vitest": "^3.0.0",
"vitest": "^4.1.9",
"typescript": "^5.7.0"
}
Comment on lines 14 to 18
"devDependencies": {
"tsx": "^4.0.0",
"vitest": "^3.0.0",
"vitest": "^4.1.9",
"typescript": "^5.7.0"
}
Comment thread package.json
Comment on lines +40 to +48
"@vitest/coverage-v8": "^4.1.9",
"cspell": "^9.7.0",
"eslint": "^10.5.0",
"eslint-plugin-n": "^18.1.0",
"highlight.js": "^11.11.1",
"markdown-it": "^14.2.0",
"markdownlint-cli2": "^0.22.1",
"typescript": "^6.0.3",
"vitest": "^3.0.0"
"vitest": "^4.1.9"
Comment thread package.json
Comment on lines +40 to +48
"@vitest/coverage-v8": "^4.1.9",
"cspell": "^9.7.0",
"eslint": "^10.5.0",
"eslint-plugin-n": "^18.1.0",
"highlight.js": "^11.11.1",
"markdown-it": "^14.2.0",
"markdownlint-cli2": "^0.22.1",
"typescript": "^6.0.3",
"vitest": "^3.0.0"
"vitest": "^4.1.9"
Copilot and others added 2 commits June 16, 2026 12:41
vitest 4 esbuild rejects duplicate imports (parseHistory was imported
twice in squad-state-gaps.test.ts). vitest 4 vi.fn(arrow) is not callable
as a constructor, so the CopilotClient mock needed a function() wrapper
that assigns to 	his.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…integration

Same pattern as adapter-client.test.ts: vitest 4 vi.fn(arrow) is not
callable as a constructor (no [[Construct]] internal slot). All three
files mock CopilotClient and instantiate it with 'new', so they need a
function() wrapper that assigns to 'this'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher
tamirdresher merged commit 04c80ab into github:dev Jun 16, 2026
14 checks passed
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