mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
* fix(test): make unit tests hermetic against host config and build state Two host-state leaks made the full suite fail deterministically on developer and agent machines while CI stayed green: - Built checkouts: bundled-plugin manifest discovery prefers dist/extensions, which by design excludes externalized official plugins (e.g. qwen). Tests that depend on manifest-driven endpoint classification (DashScope cases in media-understanding and model-compat) failed in any checkout after pnpm build. test-env now pins OPENCLAW_BUNDLED_PLUGINS_DIR to the source extensions tree (with the vitest trust opt-in) so discovery matches CI regardless of local build state; discovery tests keep managing the env per case. - unit-fast shards: setupFiles was empty, so auto-curated tests that read config saw the developer's real ~/.openclaw/openclaw.json; any key the branch schema rejects failed those tests. unit-fast and unit-fast-fake-timers now load a minimal env-isolation setup (test/setup.env.ts) that installs the isolated test home without the shared setup's module mocks. * test: update unit-fast config contract for env-isolation setup * fix(test): force unit-fast hermetic env isolation
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
// Vitest unit fast fake timers config wires the unit fast fake timers test shard.
|
|
import { defineConfig } from "vitest/config";
|
|
import { loadPatternListFromEnv, narrowIncludePatternsForCli } from "./vitest.pattern-file.ts";
|
|
import {
|
|
nonIsolatedRunnerPath,
|
|
resolveRepoRootPath,
|
|
sharedVitestConfig,
|
|
} from "./vitest.shared.config.ts";
|
|
import { getUnitFastTimerTestFiles } from "./vitest.unit-fast-paths.mjs";
|
|
|
|
export function createUnitFastFakeTimersVitestConfig(
|
|
env: Record<string, string | undefined> = process.env,
|
|
options: { argv?: string[] } = {},
|
|
) {
|
|
const sharedTest = sharedVitestConfig.test ?? {};
|
|
const includeFromEnv = loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
|
|
const unitFastTimerTestFiles = getUnitFastTimerTestFiles();
|
|
const cliInclude = narrowIncludePatternsForCli(unitFastTimerTestFiles, options.argv);
|
|
|
|
return defineConfig({
|
|
...sharedVitestConfig,
|
|
test: {
|
|
...sharedTest,
|
|
name: "unit-fast-fake-timers",
|
|
isolate: false,
|
|
runner: nonIsolatedRunnerPath,
|
|
// Env isolation only (no shared-setup mocks), mirroring unit-fast.
|
|
setupFiles: [resolveRepoRootPath("test/setup.env.ts")],
|
|
include: includeFromEnv ?? cliInclude ?? unitFastTimerTestFiles,
|
|
exclude: sharedTest.exclude ?? [],
|
|
maxWorkers: 1,
|
|
fileParallelism: false,
|
|
sequence: {
|
|
...sharedTest.sequence,
|
|
groupOrder: 1,
|
|
},
|
|
passWithNoTests: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
export default createUnitFastFakeTimersVitestConfig();
|