-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
67 lines (60 loc) · 2.16 KB
/
vitest.config.ts
File metadata and controls
67 lines (60 loc) · 2.16 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
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
import { readFileSync, existsSync } from 'fs';
import { platform } from 'os';
// Windows has issues with workerd's SQLite Durable Objects storage
// See: https://github.com/cloudflare/workers-sdk/issues - SQLITE_CANTOPEN errors
const isWindows = platform() === 'win32';
if (isWindows) {
console.warn(
'\n⚠️ Skipping e2e tests on Windows (SQLite/workerd incompatibility)\n' +
' These tests run in CI on Linux.\n'
);
}
// Read ANTHROPIC_API_KEY from .dev.vars if it exists (for local development)
function getAnthropicKey(): string {
// First check environment variable (for CI)
if (process.env.ANTHROPIC_API_KEY) {
return process.env.ANTHROPIC_API_KEY;
}
// Fall back to .dev.vars file (for local development)
if (existsSync('.dev.vars')) {
const content = readFileSync('.dev.vars', 'utf-8');
const match = content.match(/^ANTHROPIC_API_KEY=(.+)$/m);
if (match) {
// Also set it in process.env so tests can check it
process.env.ANTHROPIC_API_KEY = match[1];
return match[1];
}
}
return '';
}
const anthropicKey = getAnthropicKey();
export default defineWorkersConfig({
test: {
globals: true,
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
miniflare: {
bindings: {
ENVIRONMENT: 'test',
MAX_ORCHESTRATION_ITERATIONS: '10',
CODE_EXEC_TIMEOUT_MS: '30000',
DEFAULT_ORG: 'unfoldingWord',
// Pass API keys for real chat tests
ENGINE_API_KEY: 'test-api-key',
ANTHROPIC_API_KEY: anthropicKey,
},
kvNamespaces: ['ORG_ADMIN_KEYS', 'MCP_SERVERS', 'ORG_CONFIG', 'PROMPT_OVERRIDES'],
},
// Disable isolated storage to avoid issues with multi-request DO tests
// See: https://developers.cloudflare.com/workers/testing/vitest-integration/known-issues/#isolated-storage
isolatedStorage: false,
},
},
include: ['tests/**/*.test.ts'],
exclude: isWindows ? ['tests/e2e/**'] : [],
// Increase timeout for real API calls
testTimeout: 30000,
},
});