fix(test): isolate sync-package-json test to prevent node:fs mock contamination
sync-package-json.test.ts mocks node:fs which leaks into plugin-entry.test.ts running in the same CI batch. Move to checker/sync/ subdirectory for isolation.
This commit is contained in:
+5
-5
@@ -1,14 +1,14 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
|
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
|
||||||
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import type { PluginEntryInfo } from "./plugin-entry"
|
import type { PluginEntryInfo } from "../plugin-entry"
|
||||||
|
|
||||||
const TEST_CACHE_DIR = join(import.meta.dir, "__test-sync-cache__")
|
const TEST_CACHE_DIR = join(import.meta.dir, "__test-sync-cache__")
|
||||||
|
|
||||||
let importCounter = 0
|
let importCounter = 0
|
||||||
|
|
||||||
async function importFreshSyncPackageJsonModule(): Promise<typeof import("./sync-package-json")> {
|
async function importFreshSyncPackageJsonModule(): Promise<typeof import("../sync-package-json")> {
|
||||||
mock.module("../constants", () => ({
|
mock.module("../../constants", () => ({
|
||||||
CACHE_DIR: TEST_CACHE_DIR,
|
CACHE_DIR: TEST_CACHE_DIR,
|
||||||
PACKAGE_NAME: "oh-my-opencode",
|
PACKAGE_NAME: "oh-my-opencode",
|
||||||
NPM_REGISTRY_URL: "https://registry.npmjs.org/-/package/oh-my-opencode/dist-tags",
|
NPM_REGISTRY_URL: "https://registry.npmjs.org/-/package/oh-my-opencode/dist-tags",
|
||||||
@@ -21,11 +21,11 @@ async function importFreshSyncPackageJsonModule(): Promise<typeof import("./sync
|
|||||||
getWindowsAppdataDir: () => null,
|
getWindowsAppdataDir: () => null,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
mock.module("../../../shared/logger", () => ({
|
mock.module("../../../../shared/logger", () => ({
|
||||||
log: () => {},
|
log: () => {},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const syncPackageJsonModule = await import(`./sync-package-json?test=${importCounter++}`)
|
const syncPackageJsonModule = await import(`../sync-package-json?test=${importCounter++}`)
|
||||||
mock.restore()
|
mock.restore()
|
||||||
return syncPackageJsonModule
|
return syncPackageJsonModule
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user