fix(test): isolate tests from mock.module cache pollution
mock.module() in index-execute.test.ts permanently poisons Bun's
module cache — mock.restore() does not undo it in Bun 1.3.11.
Use cache-busted dynamic imports (../src/mod.ts?t=${Date.now()}) in
beforeEach for the three affected test files so each test gets a
fresh, unpoisoned module instance.
This commit is contained in:
@@ -4,7 +4,9 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { registerPerplexityConfigCommand } from "../src/commands/config.js";
|
||||
import { loadConfig, saveConfig } from "../src/config.js";
|
||||
|
||||
let loadConfig: (configPath?: string) => Promise<import("../src/config.js").PerplexityConfig>;
|
||||
let saveConfig: (config: import("../src/config.js").PerplexityConfig, configPath?: string) => Promise<void>;
|
||||
|
||||
let tempDir: string;
|
||||
let configPath: string;
|
||||
@@ -12,6 +14,10 @@ let configPath: string;
|
||||
beforeEach(async () => {
|
||||
tempDir = await mkdtemp(join(tmpdir(), "pi-perplexity-command-test-"));
|
||||
configPath = join(tempDir, "config.json");
|
||||
|
||||
const mod = await import(`../src/config.ts?t=${Date.now()}`);
|
||||
loadConfig = mod.loadConfig;
|
||||
saveConfig = mod.saveConfig;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
Reference in New Issue
Block a user