-
Notifications
You must be signed in to change notification settings - Fork 8
chore(deps): upgrade Vitest 3.x to 4.x (#458) #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
187a814
chore(deps): upgrade Vitest 3.x to 4.x (#458)
BigGillyStyle d9fefdb
test(repo): include .tsx in package coverage globs
BigGillyStyle 3594f68
Merge branch 'dev' into feat/458-upgrade-vitest-4
taterhead247 d952cd9
Merge branch 'dev' into feat/458-upgrade-vitest-4
BigGillyStyle d077fe1
Merge remote-tracking branch 'origin/dev' into feat/458-upgrade-vitest-4
BigGillyStyle cf0fb95
docs(repo): scrub vitest config comments, add docs/testing.md (#461)
BigGillyStyle 9bb32ca
chore(deps): upgrade Vitest to 4.1.9
BigGillyStyle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Testing & Coverage | ||
|
|
||
| How unit/integration tests and coverage are set up across the monorepo. The | ||
| per-app `vitest.config.ts` files are intentionally declarative β the rationale | ||
| behind the coverage settings lives here so it stays in one place instead of | ||
| drifting across config comments. | ||
|
|
||
| ## Running tests | ||
|
|
||
| - All packages: `pnpm test` | ||
| - A single app/package: `pnpm -C apps/map test` (append `--run` for a one-shot, | ||
| non-watch run) | ||
| - CI runs these under the `test-coverage` check (one of the five required checks | ||
| enforced by the `dev` branch ruleset β see [AGENTS.md](../AGENTS.md)). | ||
|
|
||
| Use Vitest for unit and integration tests. Name test files `*.test.ts[x]` and | ||
| place them next to the source or under `__tests__`. Reset databases before any | ||
| suite that mutates data (`pnpm reset-test-db`). | ||
|
|
||
| ## Coverage measurement (Vitest 4) | ||
|
|
||
| Vitest 4's v8 coverage provider removed the `coverage.all` option and, by | ||
| default, only measures files that a test actually imported. Left unset, an | ||
| untested file disappears from the denominator entirely, so coverage silently | ||
| answers "how much of what we imported is tested" instead of "how much of the app | ||
| is tested." | ||
|
|
||
| To preserve the v3 behaviour β untested files stay in the denominator β every | ||
| config sets `coverage.include` explicitly to the whole `src` tree | ||
| (`src/**/*.{ts,tsx}`). Apps that use the shared tooling import this rather than | ||
| hardcoding the glob: | ||
|
|
||
| ```ts | ||
| import { coverageExclude, coverageInclude } from "@acme/vitest-config"; | ||
| ``` | ||
|
|
||
| - **`coverageInclude`** β the whole-`src` glob (keeps untested files counted). | ||
| - **`coverageExclude`** β Vitest's built-in excludes plus non-testable | ||
| bootstrap/config files (Sentry init, `next.config.*`, `instrumentation*`, | ||
| Tailwind/PostCSS config, `middleware.*`). Those files would otherwise sit in | ||
| the denominator at 0% and break thresholds on every edit. | ||
|
|
||
| Both constants, and the exact glob lists, are defined and documented in | ||
| [`tooling/vitest/coverage.ts`](../tooling/vitest/coverage.ts) (the | ||
| `@acme/vitest-config` package). That file is the single source of truth β update | ||
| the globs there, not in individual app configs. | ||
|
|
||
| ## Thresholds | ||
|
|
||
| Coverage thresholds live in each app's `vitest.config.ts` under | ||
| `test.coverage.thresholds`. Two modes are in use: | ||
|
|
||
| - **`autoUpdate: true`** (e.g. `apps/api`, `apps/me`) β Vitest ratchets the | ||
| thresholds up automatically as coverage improves, guarding against | ||
| regressions without manual bookkeeping. | ||
| - **Static floors** (`apps/map`) β fixed minimums that only change by hand. | ||
|
|
||
| Note that Vitest 4's AST-aware v8 remapping counts branches and functions more | ||
| granularly than v3, so whole-`src` branch/function coverage measures lower than | ||
| it did before the upgrade. Static floors were lowered accordingly to sit just | ||
| under the v4 baseline while still catching regressions. The numbers in each | ||
| config are the source of truth β this doc deliberately doesn't repeat them. | ||
|
|
||
| ## Driving auth-bounded flows | ||
|
|
||
| Tests and QA flows that require sign-in go through `apps/auth`'s email-based MFA | ||
| against a local mail backend (no real inbox). See the | ||
| [Testing Guidelines in AGENTS.md](../AGENTS.md) and | ||
| [`docs/QA_LOCAL_AUTH.md`](QA_LOCAL_AUTH.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.