Files
openclaw/test/vitest/vitest.extension-config.ts
Peter Steinberger 896592b747 test(vitest): give config creators nameable return types
A vitest/vite type bump made inferred creator return types reach
vite-internal names (TS4058/TS4082), failing check-test-types repo-wide.
Annotate the scoped/extension config roots and the spread-rebuilding
creators with ViteUserConfig; also drop an unused workflow read, mutating
sorts, and an untyped record index left by 1f591bba56.
2026-08-10 09:35:51 -07:00

44 lines
1.3 KiB
TypeScript

// Vitest extension config helpers keep extension shard defaults aligned.
import type { ViteUserConfig } from "vitest/config";
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
type ExtensionVitestConfigOptions = {
fileParallelism?: boolean;
includeOpenClawRuntimeSetup?: boolean;
isolate?: boolean;
};
export function createExtensionVitestConfig(
name: string,
testRoots: readonly string[],
env: Record<string, string | undefined> = process.env,
options: ExtensionVitestConfigOptions = {},
): ViteUserConfig {
return createScopedVitestConfig(
loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env) ??
testRoots.map((root) => `${root}/**/*.test.ts`),
{
dir: "extensions",
env,
name: `extension-${name}`,
passWithNoTests: true,
setupFiles: ["test/setup.extensions.ts"],
...options,
},
);
}
export function createSingleChannelExtensionVitestConfig(
extensionId: string,
env: Record<string, string | undefined> = process.env,
) {
return createScopedVitestConfig([`extensions/${extensionId}/**/*.test.ts`], {
dir: "extensions",
env,
name: `extension-${extensionId}`,
passWithNoTests: true,
setupFiles: ["test/setup.extensions.ts"],
});
}