-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
27 lines (25 loc) · 964 Bytes
/
Copy pathvitest.config.ts
File metadata and controls
27 lines (25 loc) · 964 Bytes
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
import { readFileSync } from 'node:fs'
import { defineConfig } from 'vitest/config'
// Load workers/moderation YAML as raw text under vitest, matching the Worker's Wrangler `Text` rule.
const moderationYamlAsText = {
name: 'moderation-yaml-as-text',
enforce: 'pre' as const,
load(id: string) {
const path = id.split('?')[0]
if (path.includes('/workers/moderation/') && (path.endsWith('.yaml') || path.endsWith('.yml'))) {
return `export default ${JSON.stringify(readFileSync(path, 'utf-8'))}`
}
},
}
export default defineConfig({
plugins: [moderationYamlAsText],
test: {
testTimeout: 15000,
hookTimeout: 60000,
include: ['tests/**/*.test.ts'],
// Migrate + reseed the local test DB once before the suite runs, so
// integration tests have a known canonical dataset to assert against.
// Pure unit tests (tests/unit/**) don't need this but it's harmless.
globalSetup: ['./tests/global-setup.ts'],
},
})