Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
90 lines (89 loc) · 4.88 KB
/
Copy pathvitest.config.ts
File metadata and controls
90 lines (89 loc) · 4.88 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
82
83
84
85
86
87
88
89
90
import { defineConfig } from "vitest/config";
import { resolve } from "path";
export default defineConfig({
test: {
include: ["tests/**/*.test.ts"],
globals: false,
// The PDF suites (jsPDF/PDFKit) do a CPU-heavy cold-start font/module init on
// their first generate call (~13s wall-clock cold). On a loaded shared CI
// runner that first call can exceed vitest's 5s default, flaking the run and
// blocking the release (e.g. pdf-web "returns a Blob" timed out at 5000ms on
// main while passing on the PR branch and locally). Real tests finish in ms;
// a 20s floor only ever absorbs cold-start/contention, never masks a hang.
testTimeout: 20_000,
define: {
__APP_VERSION__: JSON.stringify("test"),
__COMMIT_HASH__: JSON.stringify("test"),
},
coverage: {
provider: "v8",
// `npm run test:coverage` (CI) fails under these floors. Lines, statements
// and functions hold the 90% target from codecov.yml. Branches were at 82.85%
// when this was set, so their floor is 80%.
thresholds: {
lines: 90,
statements: 90,
functions: 90,
branches: 80,
},
// What counts toward coverage. Kept to code that is unit-testable WITHOUT a
// full jsdom/browser harness so the numbers reflect logic we actually
// exercise, not unreachable DOM glue. The narrow original list
// (engine/generators/parsers/i18n) hid real gaps in the pure web helpers,
// which DO have tests but were never measured.
include: [
"src/engine/**",
"src/generators/**",
"src/parsers/**",
"src/i18n/**",
// CLI. tests/cli/ runs it as a child process, which v8 coverage does not
// measure, so it reports as uncovered; listed so that gap stays visible.
"src/cli/**",
// Pure web helpers — no DOM, no localStorage, no network. Each returns
// data or an HTML string and is unit-tested directly (see tests/web/).
"src/web/esc.ts", // HTML-escaper (XSS) — tests/web/esc.test.ts
"src/web/validation.ts", // post-parse sanity checks + issue rendering — tests/web/validation.test.ts
"src/web/asset-labels.ts", // canonical asset-category label map — tests/web/asset-labels.test.ts
"src/web/format.ts", // Spanish number formatting (fmtEur) — tests/web/format.test.ts
"src/web/charts.ts", // pure SVG/data extraction (extractChartData) — tests/web/charts.test.ts
"src/web/operations-annex.ts", // operations annex data builder (pure)
"src/web/detection-cache.ts", // broker-detection cache resolution (pure) — tests/web/detection-cache.test.ts
"src/web/year-default.ts", // default tax year + newer-years notice (pure) — tests/web/year-default.test.ts
],
// Deliberately EXCLUDED — DOM/browser-bound entry points and renderers that
// read/write document, window, localStorage, or attach event listeners.
// Unit-testing them would require standing up a jsdom harness with a built
// DOM tree (out of scope here); counting them would only depress coverage
// with code that has no pure surface to assert against. Most of their pure
// sub-logic lives in the included modules above (e.g. crypto-rate parsing
// is in src/engine/manual-rates.ts, which IS measured), but not all of it:
// storage.ts's migrateReport and section-720.ts's ISO-8859-15 encoder are
// pure and sit in excluded files. Tests for an excluded file still run
// (e.g. tests/web/storage.test.ts, tests/web/year-compare.test.ts); they
// just do not count toward coverage.
exclude: [
"src/web/main.ts", // app bootstrap, splash, wizard orchestration, file upload (heavy DOM)
"src/web/section-720.ts", // Modelo 720 DOM renderer
"src/web/section-721.ts", // Modelo 721 DOM renderer
"src/web/section-d6.ts", // Modelo D-6 DOM renderer
"src/web/section-guide.ts", // broker-guide section DOM renderer
"src/web/sidebar.ts", // hash routing + sidebar DOM toggling
"src/web/profile.ts", // fiscal-profile form (DOM + localStorage)
"src/web/broker-guides.ts", // broker card grid + guides (DOM)
"src/web/casilla-detail.ts", // expandable casilla cards (innerHTML + listeners)
"src/web/wizard.ts", // 3-step wizard DOM flow
"src/web/year-compare.ts", // year-over-year compare (DOM + localStorage)
"src/web/manual-rates.ts", // crypto-rates panel (DOM + localStorage); validation lives in src/engine/manual-rates.ts
"src/web/storage.ts", // localStorage persistence wrappers
"src/web/clipboard.ts", // navigator.clipboard wrapper
"src/web/disclaimer.ts", // legal disclaimer modal (DOM)
"src/web/env.d.ts", // ambient type declarations (no runtime code)
],
},
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
});