-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathvitest.config.mts
More file actions
46 lines (45 loc) · 1.69 KB
/
Copy pathvitest.config.mts
File metadata and controls
46 lines (45 loc) · 1.69 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
import { defineConfig } from "vitest/config";
import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
export default defineConfig({
plugins: [
// cloudflareTest registers the vite plugin that resolves cloudflare:test
// and sets the pool runner to cloudflare-pool automatically
cloudflareTest({
// Main entrypoint — required for SELF binding and DurableObject access in tests
main: "./src/index.ts",
wrangler: {
configPath: "./wrangler.jsonc",
},
// Provide a stub for LOGS (external service binding unavailable in tests)
// Override ENVIRONMENT so test-only endpoints (e.g. /api/test-seed) are accessible
miniflare: {
serviceBindings: {
LOGS: async () => new Response("ok"),
// X402_RELAY is stubbed so miniflare can start without the external service.
// Tests that exercise verifyPayment() pass their own mock via the Env argument.
X402_RELAY: async () => new Response("ok"),
},
bindings: {
ENVIRONMENT: "test",
},
},
}),
],
test: {
include: ["src/__tests__/**/*.test.ts"],
// c32check ships CJS lib files that `require` a nested @noble/hashes; the
// Workers pool can't consume that mix as an external. Pre-bundling it with
// esbuild resolves the nested dep exactly as wrangler does for production.
deps: {
optimizer: {
ssr: {
enabled: true,
include: ["c32check"],
},
},
},
// Scoring math tests call /api/leaderboard which resolves agent names with a 3s timeout.
// Increase global test timeout to avoid flaky timeouts in integration tests.
testTimeout: 15000,
},
});