-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
94 lines (91 loc) · 3.17 KB
/
Copy pathvitest.config.ts
File metadata and controls
94 lines (91 loc) · 3.17 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { defineConfig, type ViteUserConfig } from "vitest/config";
import { fileURLToPath } from "node:url";
import swc from "unplugin-swc";
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
// `demo.ts` uses bare package imports (`from "typegres"`) so the playground
// snippet reads naturally. Alias those to the source so the demo test can
// run against src without a build step.
const src = fileURLToPath(new URL("./src", import.meta.url));
// Shared by both projects (projects are separate Vite configs — root-level
// resolve/plugins don't inherit).
const shared = {
resolve: {
// Order matters — Vite matches aliases longest-first, so subpath
// entries come before the bare `typegres` root.
alias: {
"typegres/drivers/pglite": `${src}/drivers/pglite.ts`,
"typegres/drivers/sqlite": `${src}/drivers/sqlite.ts`,
"typegres/drivers/pg": `${src}/drivers/pg.ts`,
"typegres/drivers/oracle": `${src}/drivers/oracle.ts`,
"typegres/drivers/do": `${src}/drivers/do.ts`,
"typegres/postgres": `${src}/types/postgres/index.ts`,
"typegres/sqlite": `${src}/types/sqlite/index.ts`,
"typegres/oracle": `${src}/types/oracle/index.ts`,
typegres: `${src}/index.ts`,
},
},
// SWC handles TC39 stage-3 decorators (`@expose()`, `@expose.unchecked()` on
// codegen'd methods). Vite 8's default Oxc transform leaves them as-is,
// which trips the Node runtime with a SyntaxError. SWC lowers them.
// `oxc: false` disables the default; SWC owns the TS pipeline.
oxc: false as const,
plugins: [
swc.vite({
jsc: {
target: "es2022",
parser: { syntax: "typescript", decorators: true },
transform: { decoratorVersion: "2022-03" },
},
}),
],
} satisfies ViteUserConfig;
export default defineConfig({
test: {
// Bumped from the 5s default: pg-backed tests hit their limit under
// slow containers (act/docker on a single vCPU) even though they run
// in ~50ms locally.
testTimeout: 15000,
projects: [
{
...shared,
test: {
name: "node",
exclude: [
// Workerd-project tests; the default include glob wouldn't
// match them anyway, but keep the partition explicit.
"**/*.do-test.ts",
"**/node_modules/**",
"**/dist/**",
"**/.claude/**",
"**/.direnv/**",
"**/examples/**",
"packages/**",
"site/**",
],
},
},
// Real-Durable-Object tests (src/**/*.do-test.ts) run INSIDE workerd;
// the cloudflare:* modules they import are duck-type declared in
// src/live/sqlite/do-test-modules.d.ts.
{
...shared,
plugins: [
...shared.plugins,
cloudflareTest({
main: "./src/live/sqlite/do-test.worker.ts",
miniflare: {
compatibilityDate: "2025-01-01",
durableObjects: {
TEST_DO: { className: "TestDO", useSQLite: true },
},
},
}),
],
test: {
name: "workerd",
include: ["src/**/*.do-test.ts"],
},
},
],
},
});