-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathvitest.config.ts
More file actions
77 lines (74 loc) · 2.89 KB
/
Copy pathvitest.config.ts
File metadata and controls
77 lines (74 loc) · 2.89 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
68
69
70
71
72
73
74
75
76
77
import { defineConfig } from 'vitest/config'
import { playwright } from '@vitest/browser-playwright'
const browsers = ((globalThis as any).process?.env?.VITEST_BROWSERS || 'chromium')
.split(',')
.map((b: string) => ({ browser: b.trim() }))
const ALL_SPECS = ['packages/*/spec/**/*.ts', 'builds/reference/spec/**/*.js', 'builds/knockout/spec/**/*.js']
export default defineConfig({
test: {
testTimeout: 10000,
globals: true,
coverage: {
// V8 coverage runs against the `browser` project (Playwright Chromium,
// V8 runtime). Firefox/WebKit are not covered — JavaScriptCore and
// SpiderMonkey don't expose V8's coverage protocol. The authoritative
// real-browser matrix is unaffected; coverage is opt-in via
// `bun run test:coverage`.
provider: 'v8',
reporter: ['text', 'text-summary', 'html', 'lcov', 'json-summary'],
reportsDirectory: 'coverage',
// Tests load each `@tko/*` package via its `exports` (compiled `dist/`).
// We include both `dist/` (so v8 picks up execution) and `src/` (so
// source-map remapping can surface the original TS files in the report).
// builds/*/dist/browser.min.js is what tests actually load
// (vitest-setup imports it as the IIFE entry); v8 instruments
// it and source-map remap surfaces builds/*/src/index.ts in the
// report. Other dist files (browser.js, index.cjs/mjs, common.js)
// are alternate output formats not exercised by the test runner,
// so we exclude them to avoid 0% rows.
include: [
'packages/*/src/**/*.ts',
'packages/*/dist/**/*.js',
'builds/*/src/**/*.ts',
'builds/*/dist/browser.min.js'
],
// `packages/*/index.ts` are 1-line re-export barrels — exclude them.
// `builds/*/src/index.ts` is the only real source file in each build,
// so we anchor the index-exclude to packages/ only.
exclude: [
'**/spec/**',
'**/helpers/**',
'**/types/**',
'**/*.d.ts',
'**/*.cjs',
'packages/*/index.ts',
'packages/*/index.js'
],
clean: true
},
projects: [
// Authoritative real-browser matrix — UNCHANGED. Always runs every spec.
{
test: {
name: 'browser',
include: ALL_SPECS,
setupFiles: ['builds/knockout/helpers/vitest-setup.js'],
browser: { enabled: true, provider: playwright(), headless: true, instances: browsers },
globals: true,
testTimeout: 10000
}
},
// Additive CLI coverage — happy-dom.
// Intent: prove the binding engine works in a JS DOM (SSR, headless, TUI adapters).
{
test: {
name: 'cli-happy-dom',
include: ALL_SPECS,
environment: 'happy-dom',
setupFiles: ['builds/knockout/helpers/vitest-setup.js'],
globals: true
}
}
]
}
})