mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 23:19:42 -06:00
## Summary - Updates vitest and @vitest/coverage-v8 from 2.1.8 to 4.0.1 - Fixes test mocks to work with vitest 4.0's constructor support requirements ## Changes Vitest 4.0 now supports `vi.fn()` being used as constructors, which means arrow functions can no longer be used in mock implementations that will be called as constructors. ### Key refactorings: - **Class-based mocks in vi.mock()**: Defined mock classes directly in `vi.mock()` factories instead of using `.mockImplementation()` with arrow functions - **Shared mock implementations**: Created shared `vi.fn()` instances that can be configured per-test, avoiding the need for `.mockImplementation()` - **Biome linter compatibility**: The approach avoids `.mockImplementation()` entirely, preventing biome from converting `function` keywords back to arrow functions ### Files changed: - `package.json`, `package-lock.json`: vitest version updates - `test/app/config-tests.ts`: Refactored CompilerProps mocks with shared cePropsImpl - `test/app/main-tests.ts`: Refactored all constructor mocks (CompilerFinder, FormattingService, CompileHandler, etc.) ## Test plan - [x] All tests pass with `npm run test-min` - [x] Linter passes with `npm run lint` - [x] Type checking passes with `npm run ts-check` - [x] Pre-commit hooks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>