Migrate sequentialthinking and filesystem servers from Jest to Vitest

- Replace Jest dependencies with Vitest and @vitest/coverage-v8
- Update test scripts to use 'vitest run --coverage'
- Create vitest.config.ts for both servers with node environment and coverage settings
- Update all test files:
  - Change imports from '@jest/globals' to 'vitest'
  - Replace jest.mock() with vi.mock()
  - Replace jest.fn() with vi.fn()
  - Update mock clearing/restoring to use vi methods
- Remove jest.config.cjs files
- All 151 tests passing (24 in sequentialthinking, 127 in filesystem)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
olaservo
2025-10-19 11:21:58 -07:00
parent a30481da15
commit b666e7f246
15 changed files with 1497 additions and 3660 deletions

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import * as fs from 'fs/promises';
import * as path from 'path';
import * as os from 'os';

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach, jest } from '@jest/globals';
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import fs from 'fs/promises';
import path from 'path';
import os from 'os';
@@ -23,19 +23,19 @@ import {
} from '../lib.js';
// Mock fs module
jest.mock('fs/promises');
const mockFs = fs as jest.Mocked<typeof fs>;
vi.mock('fs/promises');
const mockFs = fs as any;
describe('Lib Functions', () => {
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
// Set up allowed directories for tests
const allowedDirs = process.platform === 'win32' ? ['C:\\Users\\test', 'C:\\temp', 'C:\\allowed'] : ['/home/user', '/tmp', '/allowed'];
setAllowedDirectories(allowedDirs);
});
afterEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
// Clear allowed directories after tests
setAllowedDirectories([]);
});
@@ -567,8 +567,8 @@ describe('Lib Functions', () => {
// Mock file handle with proper typing
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
mockFileHandle.read.mockResolvedValue({ bytesRead: 0 });
@@ -586,8 +586,8 @@ describe('Lib Functions', () => {
mockFs.stat.mockResolvedValue({ size: 50 } as any);
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
// Simulate reading file content in chunks
@@ -607,8 +607,8 @@ describe('Lib Functions', () => {
mockFs.stat.mockResolvedValue({ size: 100 } as any);
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
mockFileHandle.read.mockResolvedValue({ bytesRead: 0 });
@@ -626,8 +626,8 @@ describe('Lib Functions', () => {
it('opens file for reading', async () => {
// Mock file handle with proper typing
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
mockFileHandle.read.mockResolvedValue({ bytesRead: 0 });
@@ -642,8 +642,8 @@ describe('Lib Functions', () => {
it('handles files with content and returns first lines', async () => {
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
// Simulate reading file content with newlines
@@ -661,8 +661,8 @@ describe('Lib Functions', () => {
it('handles files with leftover content', async () => {
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
// Simulate reading file content without final newline
@@ -680,8 +680,8 @@ describe('Lib Functions', () => {
it('handles reaching requested line count', async () => {
const mockFileHandle = {
read: jest.fn(),
close: jest.fn()
read: vi.fn(),
close: vi.fn()
} as any;
// Simulate reading exactly the requested number of lines

View File

@@ -1,4 +1,4 @@
import { describe, it, expect } from '@jest/globals';
import { describe, it, expect } from 'vitest';
import { normalizePath, expandHome, convertToWindowsPath } from '../path-utils.js';
describe('Path Utilities', () => {

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import * as path from 'path';
import * as fs from 'fs/promises';
import * as os from 'os';

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { getValidRootDirectories } from '../roots-utils.js';
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, realpathSync } from 'fs';
import { tmpdir } from 'os';