-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitest.config.ts
More file actions
47 lines (45 loc) · 1.47 KB
/
vitest.config.ts
File metadata and controls
47 lines (45 loc) · 1.47 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
import { join } from 'node:path'
import { cloudflareTest, readD1Migrations } from '@cloudflare/vitest-pool-workers'
import { defineConfig } from 'vitest/config'
export default defineConfig(async () => {
// Read all migrations in the `migrations` directory
const migrationsPath = join(__dirname, 'migrations')
const migrations = await readD1Migrations(migrationsPath)
return {
plugins: [
cloudflareTest({
isolatedStorage: true, // Use isolated storage for each worker, **important**
wrangler: {
configPath: './wrangler.toml',
},
miniflare: {
// Add a test-only binding for migrations, so we can apply them in a
// setup file
bindings: { TEST_MIGRATIONS: migrations },
// 预先设置 vitest runner 需要的 compatibility flags,避免 debug 输出
compatibilityFlags: [
'nodejs_compat',
'enable_nodejs_tty_module',
'enable_nodejs_fs_module',
'enable_nodejs_http_modules',
'enable_nodejs_perf_hooks_module',
'enable_nodejs_v8_module',
'enable_nodejs_process_v2',
],
},
}),
],
resolve: {
tsconfigPaths: true,
alias: {
'#': join(__dirname),
},
},
test: {
globals: true,
setupFiles: ['./.vitest/apply-migrations.ts'],
include: ['tests/**/*.spec.ts', 'src/**/__tests__/**/*.spec.ts'],
exclude: ['tests/e2e'],
},
}
})