-
Notifications
You must be signed in to change notification settings - Fork 8
chore(deps): bump to vitest 4 and adjust tests after the upgrade #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 Vitest from v3.x to v4.x and introduces memfs for mocking the file system in tests. Key changes include updating test mock implementations to use named functions for better debugging and replacing direct node:fs mocks with memfs.
- Upgraded
vitestfrom^3.1.4to^4.0.0and@vitest/coverage-istanbulfrom^3.1.4to^4.0.0 - Added
memfs(^4.50.0) for file system mocking - Refactored
vi.fn().mockImplementation()to use named function expressions in test mocks - Created reusable
__mocks__files forfsandfs/promisesusingmemfs - Updated test setup in
toolhive-manager.test.tsto usevolfrommemfsfor file system state management
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated Vitest and coverage dependencies to v4.x, added memfs package |
| pnpm-lock.yaml | Updated lockfile with new dependency versions and their transitive dependencies |
| renderer/src/features/meta-mcp/components/tests/group-selector-form.test.tsx | Refactored mock to use named function expression |
| renderer/src/features/chat/hooks/tests/use-chat-streaming.test.ts | Refactored mock to use named function expression |
| renderer/src/common/hooks/tests/use-mcp-secrets.test.ts | Refactored mocks to use named function expressions |
| renderer/src/common/hooks/tests/use-download-file.test.ts | Refactored Blob mock to use named function expression |
| renderer/src/common/components/theme/tests/theme-provider.test.tsx | Refactored matchMedia mock to use named function expression |
| renderer/src/common/components/settings/tabs/tests/logs-tab.test.tsx | Refactored Blob mock to use named function expression |
| main/src/tests/toolhive-manager.test.ts | Replaced existsSync mocks with memfs, refactored mocks to use named functions, exported binPath for testing |
| main/src/tests/graceful-exit.test.ts | Refactored ElectronStore mock to use named function expression |
| main/src/tests/auto-update.test.ts | Refactored ElectronStore mock to use named function expression |
| mocks/fs/promises.cjs | Created mock for node:fs/promises using memfs |
| mocks/fs.cjs | Created mock for node:fs using memfs |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Breaking Changes Fixed
Vitest 4 requires
vi.fn()mocks to use function/class constructors instead of arrow functions.Changes
memfsfor file system mockingvi.fn().mockImplementation(() => {})tovi.fn(function Mock() {})node:child_process,node:fs,node:net) to useimportOriginaland share mock instances between named/default exportsmemfsfor file system mockingFiles Updated
Renderer:
use-chat-streaming.test.ts,use-download-file.test.ts,logs-tab.test.tsx,group-selector-form.test.tsx,use-mcp-secrets.test.ts,theme-provider.test.tsxMain:
auto-update.test.ts,graceful-exit.test.ts,toolhive-manager.test.tsAll tests passing ✅