-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvitest.workspace.js
41 lines (35 loc) · 915 Bytes
/
vitest.workspace.js
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
/**
* @import { UserWorkspaceConfig } from "vitest/config";
*/
import fs from "node:fs";
import path from "node:path";
import url from "node:url";
import { loadEnv } from "vite";
import { defineWorkspace } from "vitest/config";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/** @satisfies {NonNullable<UserWorkspaceConfig>["test"]} */
const SHARED = {
env: Object.assign(process.env, loadEnv("", path.resolve(__dirname), "")),
typecheck: {
enabled: true,
},
};
/** @see {@link https://vitest.dev/guide/workspace} */
const config = defineWorkspace(
Iterator.from(
fs.globSync(path.resolve(__dirname, "pkgs", "*"), {
withFileTypes: true,
}),
)
.filter((d) => d.isDirectory())
.map((pkg) => ({
test: {
...SHARED,
name: pkg.name,
root: path.join(pkg.parentPath, pkg.name),
},
}))
.toArray(),
);
export default config;