-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
62 lines (55 loc) · 1.58 KB
/
Copy pathvitest.config.ts
File metadata and controls
62 lines (55 loc) · 1.58 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
import * as fs from "node:fs";
import { createRequire } from "node:module";
import * as path from "node:path";
import type { Plugin } from "vite";
import { defineConfig } from "vitest/config";
// Vitest uses Vite's transform pipeline, which has no built-in .md loader.
// This plugin mirrors esbuild's `loader: { '.md': 'text' }` so that
// CopilotInstructions.ts / CopilotSkill.ts can import template files in tests.
const mdTextPlugin: Plugin = {
name: "md-text",
transform(code, id) {
if (id.endsWith(".md")) {
return `export default ${JSON.stringify(code)}`;
}
},
};
const require = createRequire(import.meta.url);
function ensureBeansMcpSourceMap(): void {
try {
const mcpEntryPath = require.resolve("@selfagency/beans-mcp");
const sourceMapPath = `${mcpEntryPath}.map`;
const sourceMap = {
version: 3,
file: path.basename(mcpEntryPath),
sources: [path.basename(mcpEntryPath)],
names: [],
mappings: "",
};
try {
fs.writeFileSync(sourceMapPath, JSON.stringify(sourceMap), {
encoding: "utf8",
flag: "wx",
});
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "EEXIST") {
throw error;
}
}
} catch {
// Optional dependency lookup; ignore when unavailable in minimal test environments.
}
}
ensureBeansMcpSourceMap();
export default defineConfig({
plugins: [mdTextPlugin],
test: {
include: ["src/test/**/*.test.ts"],
environment: "node",
},
resolve: {
alias: {
vscode: path.resolve(__dirname, "src/test/mocks/vscode.ts"),
},
},
});