Skip to main content
Glama
VITEST_MIGRATION_SUMMARY.md4.79 kB
# Vitest Migration Summary ## Overview This document summarizes all the changes made to migrate from Jest to Vitest in the lokalise-mcp project documentation. ## Completed Updates ### ✅ TESTING-GUIDE.md - Updated configuration section from `jest.config.js` to `vitest.config.ts` - Changed "Jest" to "Vitest" throughout - Updated debugging commands ### ✅ API_MOCKING_GUIDE.md - Replaced all `jest.fn()` with `vi.fn()` - Updated `jest.mock()` to `vi.mock()` - Changed `jest.Mocked` to Vitest equivalents - Added Three-Tier Mocking Architecture section - Updated all code examples to use Vitest imports ### ✅ AGENT_TASK_ASSIGNMENTS.md - Updated with current test counts (236 passing tests) - Added Three-Tier Mocking Architecture section - Updated completed tasks status ## Files Still Requiring Updates The following files still contain Jest references that need to be updated to Vitest: ### 1. MOCK_IMPLEMENTATION_EXAMPLES.md **Changes needed:** - Replace all `jest` imports with `vitest` imports - Change `jest.fn()` to `vi.fn()` - Change `jest.mock()` to `vi.mock()` - Update `jest.clearAllMocks()` to `vi.clearAllMocks()` - Remove `@jest/globals` imports, replace with `vitest` ### 2. NEW-DOMAIN-TESTING.md **Changes needed:** - Replace `@jest/globals` with `vitest` - Update all mock examples to use `vi` instead of `jest` ### 3. TEST_COVERAGE_ROADMAP.md **Changes needed:** - Update "Jest" framework references to "Vitest" - Change configuration examples from `jest.config.js` to `vitest.config.ts` ### 4. TEST_IMPLEMENTATION_GUIDE.md **Changes needed:** - Replace all `@jest/globals` imports with `vitest` - Update mock examples to use `vi` - Change configuration references ### 5. PRODUCTION_READINESS_PLAN.md **Changes needed:** - Update test runner references from Jest to Vitest - Update coverage commands to use Vitest - Change configuration examples ### 6. PHASE1-COMPLETION-REPORT.md **Changes needed:** - Update historical references (can note migration from Jest to Vitest) - Update mock factory examples ### 7. TEST-TROUBLESHOOTING.md **Changes needed:** - Update module resolution section for Vitest - Change debugging commands - Update cache clearing commands ## Key Pattern Changes ### Import Changes ```typescript // Before (Jest) import { describe, it, expect, beforeEach, jest } from "@jest/globals"; // After (Vitest) import { describe, it, expect, beforeEach, vi } from "vitest"; ``` ### Mock Function Changes ```typescript // Before (Jest) const mockFn = jest.fn(); jest.mock("./module"); jest.clearAllMocks(); // After (Vitest) const mockFn = vi.fn(); vi.mock("./module"); vi.clearAllMocks(); ``` ### Configuration Changes ```typescript // Before (jest.config.js) module.exports = { preset: "ts-jest", testEnvironment: "node", // ... }; // After (vitest.config.ts) import { defineConfig } from "vitest/config"; export default defineConfig({ test: { globals: true, environment: "node", // ... }, }); ``` ## Three-Tier Mocking Architecture The documentation now emphasizes our three-tier mocking approach: 1. **Module Mocks** (`__mocks__/`) - For layer isolation 2. **Mock Builders** (`mock-builders/`) - For realistic test data 3. **Mock Factory** (`mock-factory.ts`) - For API simulation ## Commands Update ### Test Execution ```bash # Before (Jest) npm test -- --coverage npm test -- --watch jest --clearCache # After (Vitest) npm test -- --coverage npm test -- --watch vitest --clearCache ``` ### Debugging ```bash # Before (Jest) node --inspect-brk node_modules/.bin/jest --runInBand # After (Vitest) node --inspect-brk node_modules/.bin/vitest --run ``` ## No-Any Policy All documentation now emphasizes the strict no-any policy: - NEVER use `any` types - Use `unknown` as intermediate type - Proper type assertions required - Cast through `unknown` when necessary ## Current Testing Status - **Total Tests**: 236 passing (0 failures) - **Test Files**: 11 active - **Coverage**: ~25% - **Framework**: Vitest - **Type Safety**: Strict no-any policy enforced - **Architecture**: Three-tier mocking system implemented ## Migration Benefits 1. **Faster execution**: Vitest is significantly faster than Jest 2. **Better TypeScript support**: Native ESM support 3. **Simpler configuration**: Less boilerplate 4. **Better watch mode**: More intelligent file watching 5. **Compatible API**: Similar to Jest, making migration straightforward ## Action Items For each remaining file that needs updates: 1. Read the file 2. Replace all Jest references with Vitest equivalents 3. Update code examples 4. Ensure consistency with the three-tier mocking architecture 5. Verify no `any` types are used in examples --- **Document Version**: 1.0.0 **Last Updated**: 2025-08-26 **Status**: Migration in progress

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AbdallahAHO/lokalise-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server