chore: remove jest

This commit is contained in:
Dallin Romney 2025-08-13 15:19:07 -07:00
parent 2c41dff3d5
commit 7d1bb9885f
18 changed files with 26 additions and 236 deletions

View file

@ -29,7 +29,7 @@ rules:
- readline-sync: Provides synchronous CLI user interactions
- Jest: Used for testing framework
- Vitest: Used for testing framework
All code should follow established patterns for a Node.js CLI tool

View file

@ -5,7 +5,7 @@ test
.continue
.releaserc.json
AGENTS.md
jest.config.mjs
vitest.config.ts
tsconfig.json
tsconfig.build.json
TESTING_STRATEGY.md

10
.vscode/launch.json vendored
View file

@ -24,16 +24,14 @@
],
"preLaunchTask": "watch-logs"
},
{
{
"name": "Debug Tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--no-cache"],
"program": "${workspaceFolder}/node_modules/.bin/vitest",
"args": ["--run", "--no-cache"],
"env": {
"NODE_ENV": "test",
"NODE_OPTIONS": "--experimental-vm-modules"
"NODE_ENV": "test"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",

View file

@ -5,7 +5,7 @@ This file provides guidance to AI coding agents when working with code in this r
## Development Commands
- **Build**: `npm run build` - Compiles TypeScript to JavaScript in dist/
- **Test**: `npm test` - Runs Jest tests with ESM support
- **Test**: `npm test` - Runs Vitest tests with ESM support
- **Type Check**: `npm run lint` - Runs TypeScript compiler without emitting files for type checking
- **Format**: `npm run format` - Runs Prettier with --write flag to check + fix formatting
- **Start**: `npm start` - Runs the built CLI from dist/index.js
@ -54,8 +54,8 @@ This is a CLI tool for Continue Dev that provides an interactive AI-assisted dev
### Testing Setup
- Uses Jest with TypeScript and ESM support
- Configuration in `jest.config.mjs`
- Uses Vitest with TypeScript and ESM support
- Configuration in `vitest.config.ts`
- Tests should be written with `.test.ts` extension
- No existing test files found - tests should be added when writing new functionality
- Run tests using `npm run test path/or/pattern`

View file

@ -178,7 +178,6 @@ export default [
"coverage/**",
"*.d.ts",
"src/__mocks__/**",
"jest.setup.ts",
"vitest.config.ts",
"*.config.js",
"*.config.ts",

View file

@ -1,78 +0,0 @@
import path from "path";
import { fileURLToPath } from "url";
export default {
transform: {
"\\.[jt]sx?$": ["ts-jest", { useESM: true }],
},
moduleNameMapper: {
"^(\\.{1,2}/.+)\\.js$": "$1",
"^highlight\\.js/lib/languages/(.+)$":
"<rootDir>/src/ui/__mocks__/highlightLanguage.js",
"^lowlight$": "<rootDir>/src/ui/__mocks__/lowlight.js",
"^ink-testing-library$":
"<rootDir>/node_modules/ink-testing-library/build/index.js",
"^./SyntaxHighlighter\\.js$":
"<rootDir>/src/ui/__mocks__/SyntaxHighlighter.ts",
"^./FreeTrialStatus\\.js$":
"<rootDir>/src/ui/__mocks__/FreeTrialStatus.tsx",
},
extensionsToTreatAsEsm: [".ts", ".tsx"],
preset: "ts-jest/presets/default-esm",
testTimeout: 10000,
testEnvironment: "node",
testPathIgnorePatterns: ["<rootDir>/dist/"],
modulePathIgnorePatterns: ["<rootDir>/dist/"],
transformIgnorePatterns: ["node_modules/(?!(highlight.js|lowlight)/)"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
globals: {
__dirname: path.dirname(fileURLToPath(import.meta.url)),
__filename: path.resolve(fileURLToPath(import.meta.url)),
},
resolver: "<rootDir>/jest.resolver.cjs",
// Force E2E tests to run sequentially to avoid console override conflicts
projects: [
{
displayName: "e2e",
testMatch: ["<rootDir>/src/e2e/**/*.test.ts"],
maxWorkers: 1,
transform: {
"\\.[jt]sx?$": ["ts-jest", { useESM: true }],
},
moduleNameMapper: {
"^(\\.{1,2}/.+)\\.js$": "$1",
},
extensionsToTreatAsEsm: [".ts", ".tsx"],
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
resolver: "<rootDir>/jest.resolver.cjs",
},
{
displayName: "unit",
testMatch: ["<rootDir>/src/**/*.test.{ts,tsx}"],
testPathIgnorePatterns: ["<rootDir>/src/e2e/"],
transform: {
"\\.[jt]sx?$": ["ts-jest", { useESM: true }],
},
moduleNameMapper: {
"^(\\.{1,2}/.+)\\.js$": "$1",
"^highlight\\.js/lib/languages/(.+)$":
"<rootDir>/src/ui/__mocks__/highlightLanguage.js",
"^lowlight$": "<rootDir>/src/ui/__mocks__/lowlight.js",
"^ink-testing-library$":
"<rootDir>/node_modules/ink-testing-library/build/index.js",
"^./SyntaxHighlighter\\.js$":
"<rootDir>/src/ui/__mocks__/SyntaxHighlighter.ts",
"^./FreeTrialStatus\\.js$":
"<rootDir>/src/ui/__mocks__/FreeTrialStatus.tsx",
},
extensionsToTreatAsEsm: [".ts", ".tsx"],
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
resolver: "<rootDir>/jest.resolver.cjs",
},
],
};

View file

@ -1,53 +0,0 @@
// Custom resolver for Jest to handle .js extensions in ESM project
const path = require("path");
const fs = require("fs");
module.exports = (request, options) => {
// Call the default resolver
const defaultResolver = options.defaultResolver;
// First try the default resolver
try {
return defaultResolver(request, options);
} catch (e) {
// Only continue if module not found
if (!e.message || !e.message.includes("Cannot find module")) {
throw e;
}
}
// Handle relative imports
if (request.startsWith(".")) {
const basePath = options.basedir;
const fullPath = path.resolve(basePath, request);
// Try various extensions
const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
for (const ext of extensions) {
const testPath = fullPath + ext;
try {
if (fs.existsSync(testPath)) {
return defaultResolver(testPath, options);
}
} catch (e) {
// Continue to next extension
}
}
// Also try adding /index with various extensions
for (const ext of extensions) {
const testPath = path.join(fullPath, "index" + ext);
try {
if (fs.existsSync(testPath)) {
return defaultResolver(testPath, options);
}
} catch (e) {
// Continue to next extension
}
}
}
// If still not found, throw original error
throw new Error(`Cannot find module '${request}'`);
};

View file

@ -1,31 +0,0 @@
module.exports = (path, options) => {
// Call the default resolver
const resolver = options.defaultResolver;
try {
// Try to resolve the path as-is first
return resolver(path, options);
} catch (error) {
// If the path ends with .js and resolution fails, try without the extension
if (path.endsWith(".js")) {
const pathWithoutJs = path.slice(0, -3);
try {
return resolver(pathWithoutJs, options);
} catch {
// If that also fails, try with .ts extension
try {
return resolver(pathWithoutJs + ".ts", options);
} catch {
// If that also fails, try with .tsx extension
try {
return resolver(pathWithoutJs + ".tsx", options);
} catch {
// If all attempts fail, throw the original error
throw error;
}
}
}
}
throw error;
}
};

View file

@ -1,42 +0,0 @@
import { jest } from "@jest/globals";
import { resetConsoleOverrides } from "./src/util/consoleOverride.js";
// Disable telemetry for tests
process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0";
// Mock the 'open' package to prevent browser opening during tests
jest.mock("open", () => jest.fn().mockResolvedValue(undefined));
// Mock common modules that cause issues
jest.mock("./src/logging.js");
jest.mock("./src/util/logger.js");
jest.mock("./src/hooks/useService.js");
jest.mock("./src/auth/workos.js");
jest.mock("./src/commands/commands.js");
jest.mock("./src/services/index.js");
jest.mock("./src/services/ServiceContainerContext.js");
jest.mock("./src/config.js");
jest.mock("./src/configLoader.js");
jest.mock("./src/args.js");
jest.mock("./src/services/ServiceContainer.js");
jest.mock("./src/permissions/permissionsYamlLoader.js");
jest.mock("./src/permissions/precedenceResolver.js");
// Set up global afterEach hook to clear all timers and reset console
afterEach(() => {
// Clear jest timers only if they're available
if (typeof jest !== "undefined" && jest.clearAllTimers) {
try {
jest.clearAllTimers();
} catch (e) {
// Ignore errors when clearing timers
}
}
// Reset console overrides to ensure clean state for each test
try {
resetConsoleOverrides();
} catch (e) {
// Ignore errors when resetting console
}
});

View file

@ -15,7 +15,7 @@ This document provides an overview of the different testing strategies used in t
- Testing business logic components
- Testing error handling and edge cases
**Framework**: Jest with TypeScript support
**Framework**: Vitest with TypeScript support
**Examples**:
@ -54,7 +54,7 @@ This document provides an overview of the different testing strategies used in t
- Testing component state changes
- Testing message display and formatting
**Framework**: Jest + Ink Testing Library + React Testing utilities
**Framework**: Vitest + Ink Testing Library + React Testing utilities
**Examples**:
@ -112,7 +112,7 @@ This document provides an overview of the different testing strategies used in t
## Configuration
**Jest Configuration**: [`jest.config.mjs`](../jest.config.mjs)
**Vitest Configuration**: [`vitest.config.ts`](../vitest.config.ts)
- TypeScript support with ES modules
- React/Ink component testing setup
@ -125,14 +125,14 @@ This document provides an overview of the different testing strategies used in t
# Run all tests with linting
npm test
# Run tests in watch mode (Jest only)
npx jest --watch
# Run tests in watch mode
npx vitest --watch
# Run specific test file
npx jest src/util/formatError.test.ts
npx vitest src/util/formatError.test.ts
# Run tests with coverage
npx jest --coverage
npx vitest --coverage
```
## Best Practices

View file

@ -1,5 +1,5 @@
// Mode-related slash commands have been removed per user request
// This test file is no longer needed but needs a dummy test for Jest
// This test file is no longer needed but needs a dummy test for Vitest
import { describe, it, expect } from 'vitest';

View file

@ -78,9 +78,6 @@ export function createUITestContext(
setMaxListeners: vi.fn(),
};
// Note: Jest mocks need to be hoisted, so they can't be called inside functions
// The actual mocking should be done at the top of test files
const cleanup = () => {
vi.clearAllMocks();
};

View file

@ -78,7 +78,7 @@ describe("runTerminalCommandTool", () => {
expect(elapsed).toBeLessThan(TEST_TIMEOUT_MS + 200); // Allow 200ms margin
expect(elapsed).toBeGreaterThan(TEST_TIMEOUT_MS - 100); // Allow 100ms margin
expect(result).toContain(`[Command timed out after ${TEST_TIMEOUT_MS / 1000} seconds of no output]`);
}, TEST_TIMEOUT_MS + 2000); // Set Jest timeout with buffer
}, TEST_TIMEOUT_MS + 2000); // Set test timeout with buffer
it("should not timeout commands that continuously produce output", async () => {
// Create a command that produces output at intervals shorter than timeout
@ -95,7 +95,7 @@ describe("runTerminalCommandTool", () => {
expect(result).toContain("output 1");
expect(result).toContain(`output ${iterations}`);
expect(result).not.toContain("[Command timed out");
}, TEST_TIMEOUT_MS * 3); // Set Jest timeout with buffer
}, TEST_TIMEOUT_MS * 3); // Set test timeout with buffer
it("should reset timeout when command produces stderr output", async () => {
// Create a command that produces stderr output periodically
@ -112,7 +112,7 @@ describe("runTerminalCommandTool", () => {
expect(result).toContain("done");
expect(result).toContain("Stderr: error 1");
expect(result).not.toContain("[Command timed out");
}, TEST_TIMEOUT_MS * 3); // Set Jest timeout with buffer
}, TEST_TIMEOUT_MS * 3); // Set test timeout with buffer
it("should include partial output when timing out", async () => {
// Create a command that produces some output then stops
@ -123,7 +123,7 @@ describe("runTerminalCommandTool", () => {
expect(result).toContain("initial output");
expect(result).toContain(`[Command timed out after ${TEST_TIMEOUT_MS / 1000} seconds of no output]`);
}, TEST_TIMEOUT_MS + 2000); // Set Jest timeout with buffer
}, TEST_TIMEOUT_MS + 2000); // Set test timeout with buffer
});
describe("output handling", () => {

View file

@ -5,7 +5,7 @@ import "./__tests__/TUIChat.input.test.js";
import "./__tests__/TUIChat.fileSearch.test.js";
import "./__tests__/TUIChat.slashCommands.test.js";
// Add a dummy test to satisfy Jest
// Add a dummy test to satisfy Vitest
describe("TUIChat Test Suite", () => {
it("should import all test modules", () => {
expect(true).toBe(true);

View file

@ -6,7 +6,7 @@ import { AppRoot } from "../AppRoot.js";
export type TestMode = "local" | "remote";
// Dummy test to satisfy Jest
// Dummy test to satisfy Vitest
describe("TUIChat dual mode helper", () => {
it("exports helper functions", () => {
expect(testBothModes).toBeDefined();

View file

@ -54,7 +54,7 @@ export const createProps = (overrides: any = {}) => ({
...overrides,
});
// Add a dummy test to satisfy Jest requirement
// Add a dummy test to satisfy Vitest requirement
describe("TUIChat setup", () => {
test("setup should export required functions", () => {
expect(createProps).toBeDefined();

View file

@ -54,7 +54,7 @@ export function runTest(
modes.forEach((testMode) => {
describe(`[${testMode.toUpperCase()} MODE]`, () => {
it(name, async () => {
// Import mocks from Jest setup
// Import mocks from Vitest setup
const { useServices, useService } = await import(
"../../hooks/useService.js"
);

View file

@ -159,7 +159,7 @@ export class MockRemoteServer {
}
}
// Add a dummy test to satisfy Jest requirement
// Add a dummy test to satisfy Vitest requirement
describe("MockRemoteServer", () => {
test("should be defined", () => {
expect(MockRemoteServer).toBeDefined();