forked from 0xferit/schelling-games
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.worker.ts
More file actions
47 lines (44 loc) · 1.34 KB
/
Copy pathvitest.config.worker.ts
File metadata and controls
47 lines (44 loc) · 1.34 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 path from 'node:path';
import { fileURLToPath } from 'node:url';
import {
cloudflareTest,
readD1Migrations,
} from '@cloudflare/vitest-pool-workers';
import { defineConfig } from 'vitest/config';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig(async () => {
const migrationsPath = path.join(__dirname, 'd1-migrations');
const migrations = await readD1Migrations(migrationsPath);
const runExtendedWorkerTests =
process.env.RUN_EXTENDED_WORKER_TESTS === '1';
return {
define: {
__RUN_EXTENDED_WORKER_TESTS__: JSON.stringify(runExtendedWorkerTests),
},
plugins: [
cloudflareTest({
// Keep worker tests hermetic and CI-friendly. Staging validation runs
// in a separate workflow job against a deployed Worker.
remoteBindings: false,
wrangler: { configPath: './wrangler.toml' },
miniflare: {
bindings: { TEST_MIGRATIONS: migrations },
},
}),
],
test: {
include: ['test/worker/**/*.test.ts'],
setupFiles: ['./test/worker/apply-migrations.ts'],
coverage: {
provider: 'istanbul',
include: ['src/worker.ts', 'src/worker/**/*.ts'],
thresholds: {
branches: 65,
functions: 70,
lines: 70,
statements: 70,
},
},
},
};
});