-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Expand file tree
/
Copy pathvitest.config.ts
More file actions
197 lines (194 loc) · 7.26 KB
/
Copy pathvitest.config.ts
File metadata and controls
197 lines (194 loc) · 7.26 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
* Root Vitest configuration for workspace tests that run directly against source.
*
* The aliases point package imports at their TypeScript entry points so targeted
* package tests can execute without first building every workspace.
*/
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
const root = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
test: {
environment: "node",
testTimeout: 120_000,
hookTimeout: 120_000,
exclude: [
"**/node_modules/**",
"**/dist/**",
"**/.git/**",
// Tool worktrees are root containers; same-named nested paths remain tests.
".worktrees/**",
".audit-worktrees/**",
".codex-worktrees/**",
".codex-pr-worktrees/**",
".codex-agent-worktrees/**",
"**/.claude/**",
"**/.eliza/**",
"**/.tmp/**",
"**/tmp/**",
"**/*.e2e.test.{ts,tsx}",
"**/*.e2e.spec.{ts,tsx}",
"**/*.live.test.{ts,tsx}",
"**/*.live.e2e.test.{ts,tsx}",
"**/*.real.test.{ts,tsx}",
"**/*.real.e2e.test.{ts,tsx}",
],
},
resolve: {
alias: [
{
// plugin-app-control's build (tsup, index + worker entries only)
// never emits dist/actions/*.js; the agent's settings-actions.ts
// subpath import resolves only under the `eliza-source` exports
// condition, which vite's resolver ignores. Pin it to source so any
// test whose graph loads @elizaos/agent (aliased to src below) boots.
find: /^@elizaos\/plugin-app-control\/actions\/settings$/,
replacement: path.join(
root,
"plugins/plugin-app-control/src/actions/settings.ts",
),
},
{
find: /^@elizaos\/app-core$/,
replacement: path.join(root, "packages/app-core/src/index.ts"),
},
{
find: /^@elizaos\/app-core\/(.+)$/,
replacement: path.join(root, "packages/app-core/src/$1"),
},
{
find: /^@elizaos\/agent$/,
replacement: path.join(root, "packages/agent/src/index.ts"),
},
{
find: /^@elizaos\/agent\/(.+)$/,
replacement: path.join(root, "packages/agent/src/$1"),
},
{
// The agent's settings action imports the shared parser from this
// subpath (#14804); app-control's build bundles only the barrel, so
// without the eliza-source condition the subpath has no dist file to
// resolve to and must be pinned to source here.
find: /^@elizaos\/plugin-app-control\/(.+)$/,
replacement: path.join(root, "plugins/plugin-app-control/src/$1"),
},
{
find: /^@elizaos\/logger$/,
replacement: path.join(root, "packages/logger/src/index.ts"),
},
{
find: /^@elizaos\/core$/,
replacement: path.join(root, "packages/core/src/index.node.ts"),
},
{
find: /^@elizaos\/core\/atomic-json$/,
replacement: path.join(root, "packages/core/src/utils/atomic-json.ts"),
},
{
// "./node" is an exports-map subpath (→ index.node.ts), not a real
// src path, so it must be pinned before the generic src/$1 rewrite.
find: /^@elizaos\/core\/node$/,
replacement: path.join(root, "packages/core/src/index.node.ts"),
},
{
find: /^@elizaos\/core\/(.+)$/,
replacement: path.join(root, "packages/core/src/$1"),
},
{
find: /^@elizaos\/shared$/,
replacement: path.join(root, "packages/shared/src/index.ts"),
},
{
find: /^@elizaos\/shared\/(.+)$/,
replacement: path.join(root, "packages/shared/src/$1"),
},
{
// Leaf auth package (account storage, credentials, oauth flows,
// atomic-json). It ships no dist in the test lane, so its `.` and `./*`
// exports resolve to `dist/*.js` and vite fails with "Cannot find
// package '@elizaos/auth/...'". Pin both the barrel and subpaths to
// source so targeted tests (e.g. remote-plugin-adapter → app-package
// -modules → `@elizaos/core/atomic-json`) resolve without a build.
find: /^@elizaos\/auth$/,
replacement: path.join(root, "packages/auth/src/index.ts"),
},
{
find: /^@elizaos\/auth\/(.+)$/,
replacement: path.join(root, "packages/auth/src/$1"),
},
{
find: /^@elizaos\/vault$/,
replacement: path.join(root, "packages/vault/src/index.ts"),
},
{
find: /^@elizaos\/vault\/(.+)$/,
replacement: path.join(root, "packages/vault/src/$1"),
},
{
find: /^@elizaos\/cloud-sdk$/,
replacement: path.join(root, "packages/cloud/sdk/src/index.ts"),
},
{
find: /^@elizaos\/cloud-sdk\/(.+)$/,
replacement: path.join(root, "packages/cloud/sdk/src/$1"),
},
{
// Core's src re-exports the cloud routing surface from
// `@elizaos/cloud-routing` (packages/core/src/cloud-routing.ts), which
// ships no dist. With @elizaos/core source-aliased above, that re-export
// only resolves when cloud-routing is pinned to source too — otherwise
// vite falls through to its `dist/index.js` entry and fails with
// "Failed to resolve entry for @elizaos/cloud-routing".
find: /^@elizaos\/cloud-routing$/,
replacement: path.join(root, "packages/cloud/routing/src/index.ts"),
},
{
find: /^@elizaos\/cloud-routing\/(.+)$/,
replacement: path.join(root, "packages/cloud/routing/src/$1"),
},
{
find: /^@elizaos\/ui$/,
replacement: path.join(root, "packages/ui/src/index.ts"),
},
{
find: /^@elizaos\/ui\/(.+)$/,
replacement: path.join(root, "packages/ui/src/$1"),
},
{
find: /^@elizaos\/vault$/,
replacement: path.join(root, "packages/vault/src/index.ts"),
},
{
find: /^@elizaos\/vault\/(.+)$/,
replacement: path.join(root, "packages/vault/src/$1"),
},
{
// plugin-commands ships only a built `dist/` entry, so a test run
// straight from source (targeted package tests, the changed-files
// coverage gate) fails to resolve its `.`/`./*` exports with "Failed to
// resolve entry for @elizaos/plugin-commands" whenever a graph pulls in
// the Discord connector (service.ts → catalog-commands.ts). Pin barrel
// and subpaths to source; mirrors plugin-discord/vitest.config.ts so the
// per-package lane and this root lane resolve identically.
find: /^@elizaos\/plugin-commands$/,
replacement: path.join(root, "plugins/plugin-commands/src/index.ts"),
},
{
find: /^@elizaos\/plugin-commands\/(.+)$/,
replacement: path.join(root, "plugins/plugin-commands/src/$1"),
},
{
// Same source-resolution story for @elizaos/plugin-meetings: the Discord
// voice-meeting seams import its barrel, and it too ships no dist in the
// test lane.
find: /^@elizaos\/plugin-meetings$/,
replacement: path.join(root, "plugins/plugin-meetings/src/index.ts"),
},
{
find: /^@elizaos\/plugin-meetings\/(.+)$/,
replacement: path.join(root, "plugins/plugin-meetings/src/$1"),
},
],
},
});