Skip to content

Commit ca6b13d

Browse files
committed
Tooling: Switch vitest to happy-dom (faster DOM env)
- happy-dom's per-file DOM-environment setup is ~half jsdom's cost (the dominant phase for our ~3300 tests) - ~22% faster on a plain/watch run; the gated (coverage) run is a smaller but real win. All 3318 tests pass under it. - jsdom kept installed as the per-file fallback (`// @vitest-environment jsdom`) since happy-dom implements a subset of its APIs; knip is fine with it. - happy-dom added via `--trust-policy-exclude chokidar --trust-policy-exclude semver` (both mainstream transitive deps whose old versions predate npm provenance; see pnpm-workspace.yaml).
1 parent 19a090e commit ca6b13d

3 files changed

Lines changed: 58 additions & 8 deletions

File tree

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"eslint-config-prettier": "^10.1.8",
6565
"eslint-plugin-svelte": "^3.17.1",
6666
"globals": "^17.5.0",
67+
"happy-dom": "^20.9.0",
6768
"jsdom": "^29.0.2",
6869
"knip": "^6.7.0",
6970
"oxlint": "^1.61.0",

apps/desktop/vitest.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export default defineConfig({
77
plugins: [Icons({ compiler: 'svelte' }), svelte()],
88
test: {
99
include: ['src/**/*.test.ts', 'scripts/**/*.test.js', 'test/e2e-shared/**/*.test.ts'],
10-
environment: 'jsdom',
10+
// happy-dom over jsdom: its per-file DOM-environment setup is roughly half
11+
// the cost (the dominant phase for our ~3300 tests), ~22% faster on a plain
12+
// run. All tests pass under it. Caveat: happy-dom implements a *subset* of
13+
// jsdom's APIs — if a future test fails on a missing DOM API, switch that
14+
// file back with `// @vitest-environment jsdom` (jsdom stays installed).
15+
environment: 'happy-dom',
1116
globals: true,
1217
setupFiles: ['./src/test-setup.ts'],
1318
execArgv: ['--localstorage-file=.vitest-localstorage'],

pnpm-lock.yaml

Lines changed: 51 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)