Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
81 lines (78 loc) · 2.72 KB
/
Copy pathvitest.config.ts
File metadata and controls
81 lines (78 loc) · 2.72 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
78
79
80
81
import { defineConfig } from 'vitest/config'
import packageJson from './package.json' with { type: 'json' }
// Tests split across two storage backends. The vast majority only exercise the
// storage *contract*, so they run against the Map-backed in-memory adapter
// (`@tanstack/cms-store-memory`) — no PGlite WASM boot or per-op round-trips,
// which roughly halves total test-work and makes coverage runs far cheaper.
// The files below genuinely need Postgres-only capabilities the in-memory
// adapter deliberately omits (transactional outbox / cron schedules, editorial
// comments, API keys, DB-auth users, user→role mappings, unique-index
// enforcement), so they stay on the embedded PGlite engine.
const pgliteOnly = [
'tests/collaboration.test.ts', // CommentOps
'tests/db-auth.test.ts', // AuthUserOps
'tests/events.test.ts', // OutboxOps
'tests/interface-schedules.test.ts', // OutboxOps cron schedules
'tests/seo.test.ts', // unique-index enforcement
'tests/transfer.test.ts', // ApiKeyOps
'tests/user-roles.test.ts', // UserRoleOps
'tests/webhooks-outbox.test.ts', // OutboxOps
]
const shared = {
dir: './',
watch: false,
globals: true,
environment: 'node' as const,
// DB-backed tests (embedded PGlite) boot WASM and some bulk-import thousands
// of documents; the 5s default flakes on loaded CI runners. Give headroom.
testTimeout: 60_000,
hookTimeout: 60_000,
}
export default defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov'],
exclude: [
'node_modules/',
'dist/',
'tests/',
'src/routes/',
// The storage conformance suite is test code that ships in src/ so
// adapter authors can import it (`@tanstack/cms-core/storage/
// conformance`). It only runs against the store packages, never core's
// own tests, so counting its ~123 test functions as uncovered
// production code understates core's real coverage by ~6 points.
'src/storage/conformance.ts',
'**/*.test.ts',
'**/*.config.ts',
],
include: ['src/**/*.{ts,tsx}'],
thresholds: {
statements: 78,
branches: 65,
functions: 80,
lines: 80,
},
},
projects: [
{
test: {
...shared,
name: `${packageJson.name} (memory)`,
setupFiles: ['@tanstack/cms-store-memory/testing'],
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
exclude: pgliteOnly,
},
},
{
test: {
...shared,
name: `${packageJson.name} (pglite)`,
setupFiles: ['@tanstack/cms-store-postgres/testing'],
include: pgliteOnly,
},
},
],
},
})