test: migrate from Jest to Vitest (Phase 1 complete)
- Remove Jest and all related packages - Install Vitest with coverage support - Create vitest.config.ts with path aliases - Set up global test configuration - Migrate all 6 test files to Vitest syntax - Update TypeScript configuration for better Vitest support - Create separate tsconfig.build.json for clean builds - Fix all import/module issues in tests - All 68 tests passing successfully - Current coverage baseline: 2.45% Phase 1 of testing suite improvement complete. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import {
|
||||
MCPError,
|
||||
N8NConnectionError,
|
||||
@@ -11,9 +12,9 @@ import {
|
||||
import { logger } from '../src/utils/logger';
|
||||
|
||||
// Mock the logger
|
||||
jest.mock('../src/utils/logger', () => ({
|
||||
vi.mock('../src/utils/logger', () => ({
|
||||
logger: {
|
||||
error: jest.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -158,7 +159,7 @@ describe('handleError', () => {
|
||||
|
||||
describe('withErrorHandling', () => {
|
||||
it('should execute operation successfully', async () => {
|
||||
const operation = jest.fn().mockResolvedValue('success');
|
||||
const operation = vi.fn().mockResolvedValue('success');
|
||||
|
||||
const result = await withErrorHandling(operation, 'test operation');
|
||||
|
||||
@@ -168,7 +169,7 @@ describe('withErrorHandling', () => {
|
||||
|
||||
it('should handle and log errors', async () => {
|
||||
const error = new Error('Operation failed');
|
||||
const operation = jest.fn().mockRejectedValue(error);
|
||||
const operation = vi.fn().mockRejectedValue(error);
|
||||
|
||||
await expect(withErrorHandling(operation, 'test operation')).rejects.toThrow();
|
||||
|
||||
@@ -177,7 +178,7 @@ describe('withErrorHandling', () => {
|
||||
|
||||
it('should transform errors using handleError', async () => {
|
||||
const error = { code: 'ECONNREFUSED' };
|
||||
const operation = jest.fn().mockRejectedValue(error);
|
||||
const operation = vi.fn().mockRejectedValue(error);
|
||||
|
||||
try {
|
||||
await withErrorHandling(operation, 'test operation');
|
||||
|
||||
Reference in New Issue
Block a user