-
Notifications
You must be signed in to change notification settings - Fork 324
/
vitest.workspace.ts
55 lines (51 loc) · 1.43 KB
/
vitest.workspace.ts
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
54
55
import { existsSync, readdirSync } from "node:fs";
import { defineWorkspace, mergeConfig, ViteUserConfig } from "vitest/config";
const pkgRoot = (pkg: string) =>
new URL(`./packages/${pkg}`, import.meta.url).pathname;
const alias = (pkg: string) => `${pkgRoot(pkg)}/src`;
const aliases = readdirSync(new URL("./packages", import.meta.url).pathname)
.filter((dir) => existsSync(pkgRoot(dir) + "/package.json"))
.filter((dir) => dir !== "uploadthing")
.reduce<Record<string, string>>(
(acc, pkg) => {
acc[`@uploadthing/${pkg}`] = alias(pkg);
return acc;
},
{ uploadthing: alias("uploadthing") },
);
const baseConfig: ViteUserConfig = {
test: {
mockReset: true,
coverage: {
provider: "v8",
include: ["**/src/**"],
exclude: ["**/docs/**", "**/examples/**", "**/tooling/**"],
},
},
esbuild: { target: "es2020" },
resolve: { alias: aliases },
};
export default defineWorkspace([
mergeConfig(baseConfig, {
test: {
include: [
"**/*.test.{ts,tsx}",
"!**/*.browser.test.{ts,tsx}",
"!**/*.e2e.test.{ts,tsx}",
],
name: "unit",
environment: "node",
},
} satisfies ViteUserConfig),
mergeConfig(baseConfig, {
test: {
include: ["**/*.browser.test.{ts,tsx}"],
name: "browser",
browser: {
provider: "playwright",
enabled: true,
name: "chromium",
},
},
} satisfies ViteUserConfig),
]);