forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
122 lines (120 loc) · 4.67 KB
/
Copy pathvitest.config.ts
File metadata and controls
122 lines (120 loc) · 4.67 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
/** Vitest config for the unit suite — aliases sibling plugin and package `src` dirs so tests resolve them from source. */
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
const rootDir = dirname(fileURLToPath(import.meta.url));
const toVitePath = (value: string): string => value.replaceAll("\\", "/");
const coreSrc = resolve(rootDir, "../../packages/core/src");
const pluginBrowserSrc = resolve(rootDir, "../plugin-browser/src");
const pluginCommandsSrc = resolve(rootDir, "../plugin-commands/src");
const pluginTrainingSrc = resolve(rootDir, "../plugin-training/src");
const sharedSrc = resolve(rootDir, "../../packages/shared/src");
const importConversationsSrc = resolve(
rootDir,
"../../packages/import-conversations/src",
);
export default defineConfig({
resolve: {
alias: [
// Changed-test coverage runs before workspace builds, so command imports
// must resolve core from source rather than an absent dist entrypoint.
{
find: /^@elizaos\/core$/,
replacement: toVitePath(resolve(coreSrc, "index.ts")),
},
{
find: /^@elizaos\/core\/(.+)$/,
replacement: `${toVitePath(coreSrc)}/$1`,
},
// `@elizaos/ui` is aliased to source (below). Its module graph imports many
// `@elizaos/shared/*` subpaths (voice-eot, transcripts, contracts/*, …) that
// only ship from `dist/`, which is frequently stale or unbuilt when this
// package's suite runs standalone — causing the whole suite to fail to load.
// Resolve `@elizaos/shared` to source too (this suite runs in the `node`
// environment, so node-only shared modules load fine), mirroring how ui,
// plugin-browser, and plugin-training are already redirected to source above.
{
find: /^@elizaos\/shared$/,
replacement: toVitePath(resolve(sharedSrc, "index.ts")),
},
{
find: /^@elizaos\/shared\/(.+)$/,
replacement: `${toVitePath(sharedSrc)}/$1`,
},
{
find: /^@elizaos\/ui$/,
replacement: toVitePath(
resolve(rootDir, "../../packages/ui/src/index.ts"),
),
},
{
find: /^@elizaos\/ui\/(.+)$/,
replacement: `${toVitePath(resolve(rootDir, "../../packages/ui/src"))}/$1`,
},
// `@elizaos/ui` (aliased to source above) pulls MemoryViewerView, which
// imports the `@elizaos/import-conversations/browser` subpath. That subpath
// only resolves to source through the package's `eliza-source` export
// condition, which vitest does not apply — bare resolution falls through to
// `./dist`, absent when this suite runs standalone (the Windows CI lane
// builds only core/shared). Anchor it to source; import-conversations/src
// has no external deps, so this is self-contained.
{
find: /^@elizaos\/import-conversations$/,
replacement: toVitePath(resolve(importConversationsSrc, "index.ts")),
},
{
find: /^@elizaos\/import-conversations\/(.+)$/,
replacement: `${toVitePath(importConversationsSrc)}/$1`,
},
{
find: /^@elizaos\/plugin-health\/screen-time\/mobile-signal-setup$/,
replacement: toVitePath(
resolve(
rootDir,
"../plugin-health/src/screen-time/mobile-signal-setup.ts",
),
),
},
{
// `src/index.ts` now contributes a slash command via
// `@elizaos/plugin-commands`. Resolve it to source (it ships no prebuilt
// dist when the suite runs standalone), mirroring the redirects above.
find: /^@elizaos\/plugin-commands$/,
replacement: toVitePath(resolve(pluginCommandsSrc, "index.ts")),
},
{
find: /^@elizaos\/plugin-commands\/(.+)$/,
replacement: `${toVitePath(pluginCommandsSrc)}/$1`,
},
{
find: /^@elizaos\/plugin-browser$/,
replacement: toVitePath(resolve(pluginBrowserSrc, "index.ts")),
},
{
find: /^@elizaos\/plugin-browser\/(.+)$/,
replacement: `${toVitePath(pluginBrowserSrc)}/$1`,
},
{
find: /^@elizaos\/plugin-training$/,
replacement: toVitePath(resolve(pluginTrainingSrc, "index.ts")),
},
{
find: /^@elizaos\/plugin-training\/(.+)$/,
replacement: `${toVitePath(pluginTrainingSrc)}/$1`,
},
],
},
test: {
environment: "node",
include: [
"__tests__/**/*.test.ts",
"__tests__/**/*.test.tsx",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/__tests__/**/*.test.ts",
"src/__tests__/**/*.test.tsx",
],
testTimeout: 60_000,
hookTimeout: 60_000,
},
});