| 1 | import { vi } from "vitest"; |
| 2 | |
| 3 | import { resetConsoleOverrides } from "./src/init.js"; |
| 4 | |
| 5 | // Disable telemetry for tests |
| 6 | process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0"; |
| 7 | |
| 8 | // Mock the 'open' package to prevent browser opening during tests |
| 9 | vi.mock("open", () => ({ |
| 10 | default: vi.fn().mockResolvedValue(undefined), |
| 11 | })); |
| 12 | |
| 13 | // Mock constructSystemMessage to avoid service container issues in tests |
| 14 | vi.mock("./src/systemMessage.js", () => ({ |
| 15 | constructSystemMessage: vi |
| 16 | .fn() |
| 17 | .mockResolvedValue( |
| 18 | "You are an agent in the Continue CLI. Given the user's prompt, you should use the tools available to you to answer the user's question.", |
| 19 | ), |
| 20 | })); |
| 21 | |
| 22 | // Mock environment for tests |
| 23 | process.env.CONTINUE_GLOBAL_DIR = "/tmp/continue-test"; |
| 24 | |
| 25 | // Set up global afterEach hook to clear all timers and reset console |
| 26 | afterEach(() => { |
| 27 | // Clear vitest timers |
| 28 | vi.clearAllTimers(); |
| 29 | |
| 30 | // Reset console overrides to ensure clean state for each test |
| 31 | try { |
| 32 | resetConsoleOverrides(); |
| 33 | } catch { |
| 34 | // Ignore errors when resetting console |
| 35 | } |
| 36 | }); |