forked from monkeytypegame/monkeytype
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
53 lines (47 loc) · 1.41 KB
/
vitest.config.ts
File metadata and controls
53 lines (47 loc) · 1.41 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
46
47
48
49
50
51
52
53
import { defineConfig, UserWorkspaceConfig } from "vitest/config";
import { projects as backendProjects } from "./backend/vitest.config";
import { projects as frontendProjects } from "./frontend/vitest.config";
//oxlint-disable-next-line no-explicit-any
let globalPlugins: any[] = [];
export default defineConfig({
test: {
projects: [
...convertTests(backendProjects, "backend"),
...convertTests(frontendProjects, "frontend"),
"packages/**/vitest.config.ts",
],
},
plugins: globalPlugins,
});
function convertTests(
projects: unknown[],
root: string,
): UserWorkspaceConfig[] {
return (projects as UserWorkspaceConfig[]).map((it) => {
const test = it.test ?? {};
const name: string | { label: string } = test.name ?? "unknown";
copySolidPlugin(it);
let updatedName =
name === null || typeof name === "string"
? `${name}-${root}`
: { ...name, label: `${name.label}-${root}` };
return {
...it,
test: {
...test,
root,
name: updatedName,
},
} as UserWorkspaceConfig;
});
}
/**
* Tests for solidJs need the solid plugin to run on config level and on test level. idk why
*/
function copySolidPlugin(config: UserWorkspaceConfig): void {
if (!config.plugins) return;
config.plugins
//@ts-expect-error this is fine
.filter((it) => it?.name === "solid")
.forEach((it) => globalPlugins.push(it));
}