forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathvitest.unit.config.ts
More file actions
45 lines (40 loc) · 1.47 KB
/
vitest.unit.config.ts
File metadata and controls
45 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { defineConfig } from "vitest/config";
import baseConfig from "./vitest.config.ts";
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
import { resolveVitestIsolation } from "./vitest.scoped-config.ts";
import {
unitTestAdditionalExcludePatterns,
unitTestIncludePatterns,
} from "./vitest.unit-paths.mjs";
const base = baseConfig as unknown as Record<string, unknown>;
const baseTest = (baseConfig as { test?: { include?: string[]; exclude?: string[] } }).test ?? {};
const exclude = baseTest.exclude ?? [];
export function loadIncludePatternsFromEnv(
env: Record<string, string | undefined> = process.env,
): string[] | null {
return loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
}
export function loadExtraExcludePatternsFromEnv(
env: Record<string, string | undefined> = process.env,
): string[] {
return loadPatternListFromEnv("OPENCLAW_VITEST_EXTRA_EXCLUDE_FILE", env) ?? [];
}
export function createUnitVitestConfig(env: Record<string, string | undefined> = process.env) {
return defineConfig({
...base,
test: {
...baseTest,
isolate: resolveVitestIsolation(env),
runner: "./test/non-isolated-runner.ts",
include: loadIncludePatternsFromEnv(env) ?? unitTestIncludePatterns,
exclude: [
...new Set([
...exclude,
...unitTestAdditionalExcludePatterns,
...loadExtraExcludePatternsFromEnv(env),
]),
],
},
});
}
export default createUnitVitestConfig();