Skip to content

test: exclude dist from vitest runs in every package - #254

Merged
dangreen merged 1 commit into
mainfrom
test/vitest-exclude-dist
Sep 8, 2026
Merged

test: exclude dist from vitest runs in every package#254
dangreen merged 1 commit into
mainfrom
test/vitest-exclude-dist

Conversation

@dangreen

@dangreen dangreen commented Sep 8, 2026

Copy link
Copy Markdown
Member

Why

Every package config builds its vitest exclude as [...configDefaults.exclude, './package']. In the installed vitest 5, configDefaults.exclude is only **/node_modules/** and **/.git/**, so dist is no longer excluded.

svelte-router is where it bites: svelte-package compiles everything under src, specs included, into dist. The build script cleans them with clear:dist-assets, but test:dist-types runs build:dist alone, so after pnpm test:types a stale dist/core.spec.js stays behind and the next vitest run executes it against outdated code.

Reproduced with a throwing dist/stale.spec.js in packages/svelte-router: vitest run picked it up and failed; with ./dist excluded the same file is skipped.

What

exclude: [...configDefaults.exclude, './package', './dist'] in all 19 packages/*/vite.config.js, in the style of the existing ./package entry. svelte-router keeps its extra ./.svelte-kit.

Checks

  • oxlint on the configs passes.
  • vitest run spot-checked in kida, react, svelte and svelte-router with unchanged counts.

The package vitest configs build their `exclude` list on `configDefaults.exclude`, which no longer contains `**/dist/**` in vitest 5, so a compiled spec left in `dist` runs as a test. `svelte-router` produces exactly that: `svelte-package` compiles `src/*.spec.ts` into `dist`, and `test:dist-types` runs `build:dist` without the `clear:dist-assets` step, after which `vitest run` executes the stale `dist/*.spec.js` and fails. Every config now excludes `./dist` next to `./package`.
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.33%. Comparing base (568df71) to head (2197b35).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #254   +/-   ##
=======================================
  Coverage   83.33%   83.33%           
=======================================
  Files          98       98           
  Lines        2557     2557           
  Branches      552      552           
=======================================
  Hits         2131     2131           
  Misses        314      314           
  Partials      112      112           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dangreen
dangreen merged commit 5d9c68d into main Sep 8, 2026
10 checks passed
@dangreen
dangreen deleted the test/vitest-exclude-dist branch September 8, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant