Vitest 37 🧪 v4 Breaking Changes — maxWorkers, reporter changes, and coverage defaults
Vitest 4 is the first major release since the 1.0 line that deliberately removes options instead of only adding them. The theme of the release is consolidation: the worker configuration that accumulated three generations of deprecated flags under poolOptions collapses into a handful of top-level keys, the reporter set loses the long-obsolete basic reporter, and the coverage engine drops the toggles that no longer made sense after the v8 remapping rewrite. None of these changes add a feature in the flashy sense — they change what a v3 configuration file means.
The chapters that follow assume a project already on Vitest 3 and about to move to Vitest 4. The first section explains why the removals happened at all. The next three sections cover the actual breaking surface: the maxWorkers / minWorkers / pool-option migration, the reporter changes, and the coverage defaults. After that, a complete example session migrates a real config file part by part, followed by the quick reference, best practices, pitfalls, ten real-world snippets, the visual diagrams, and the summary.
Key point: Vitest 4 deletes the deprecated configuration layer instead of translating it. A v3 config file that still uses poolOptions, the basic reporter, or coverage.all does not fail silently with identical behaviour — the option is gone, so the value it produced is gone too, and the migration has to name the replacement explicitly.
Why v4 exists
The accumulated-deprecation problem. Vitest grew its worker options over three minor lines. Vitest 1 introduced the threads and forks pools with per-pool maxThreads, minThreads, maxForks, minForks, singleThread, and singleFork. Vitest 2 added vmThreads and repeated the same options for it. Vitest 3 kept all of them and layered maxWorkers and minWorkers on top as the intended replacement. By Vitest 4 the config type had two ways to express nearly every worker limit, and the schema had to reconcile them at runtime. Major versions exist to end that reconciliation.
The configuration-surface problem. Every per-pool option was a duplicate of a top-level option. poolOptions.threads.maxThreads and poolOptions.forks.maxForks both meant “the most workers this run may use,” but the runtime had to read them from separate branches because the pool was not known until the pool was selected. The duplication made the type definition large, the config validation slow, and the documentation show four ways to say one thing. Collapsing them to maxWorkers removes the duplication and makes the limit independent of which pool is active.
The reporter-noise problem. The basic reporter was a thin wrapper around the default that produced a slightly different summary. It was kept for compatibility long after the default reporter had absorbed the useful parts. Keeping two near-identical reporters means every reporter-API change has to be applied twice and every bug report has to specify which of the two produced the output. Removing basic leaves one default, one verbose, and the machine-readable formats.
The coverage-accuracy problem. The coverage engine in v3 could report a file that the tests never imported only if coverage.all was set, and it counted empty lines unless coverage.ignoreEmptyLines was set to true, and it had to run a second “experimental” remapping pass to attribute coverage to the original TypeScript source when the test ran the transpiled output. The experimental path was faster and more accurate, so v4 makes it the only path and removes the toggle. The other toggles were symptoms of the same underlying mismatch between what the runner executed and what the report described.
The clean-slate trade-off. Removing an option is a breaking change even when a replacement exists, because a config file is code: it is read by the config loader, it is type-checked by the editor, and it is often shared across a monorepo. The migration is mechanical but it is not free, and v4 accepts the one-time cost in exchange for a config surface that is half the size of v3’s.
The mixed-version risk. A project that upgrades the vitest package but leaves a v3 config file does not get a warning for every removed key. Some keys are dropped by the schema, some are still accepted but no longer do anything, and some are now type errors. The release notes are the authoritative list, and the migration is the reader’s responsibility.
a. maxWorkers and the removal of poolOptions
The worker configuration in v3 had two layers. The first was the pool: pool: 'threads' | 'forks' | 'vmThreads', which chose the isolation model. The second was poolOptions, a per-pool object whose keys depended on the pool. poolOptions.threads accepted maxThreads, minThreads, and singleThread; poolOptions.forks accepted maxForks, minForks, and singleFork; poolOptions.vmThreads repeated the thread options. The top-level maxWorkers and minWorkers were added in v3 as the intended replacement, and v4 completes the move by deleting poolOptions.
// vitest.config.ts — the Vitest 3 form
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
// Pool selection stays; this part is unchanged in v4
pool: "threads",
poolOptions: {
threads: {
maxThreads: 4, // the worker ceiling for the threads pool
minThreads: 1, // the worker floor kept warm
singleThread: false,
},
},
},
});
The v4 equivalent moves every limit to the top level. The threads and forks sub-objects disappear; maxWorkers and minWorkers apply regardless of the chosen pool, and the single-worker shortcut becomes the top-level singleThread or singleFork depending on the pool.
// vitest.config.ts — the Vitest 4 form
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
pool: "threads", // unchanged: the pool still selects the isolation model
maxWorkers: 4, // replaces poolOptions.threads.maxThreads
minWorkers: 1, // replaces poolOptions.threads.minThreads
singleThread: false, // replaces poolOptions.threads.singleThread
},
});
The mapping is one-to-one, and it is worth writing out because the same table handles the forks pool. poolOptions.forks.maxForks becomes maxWorkers, poolOptions.forks.minForks becomes minWorkers, and poolOptions.forks.singleFork becomes singleFork. The pool name is the only part that stays in its original place. A project that used poolOptions.vmThreads.maxThreads moves that value to maxWorkers too, because the limit is not pool-specific.
The default maxWorkers is the number of cores the operating system reports as available, which on most machines equals os.availableParallelism(). A project that never set a limit does not need to add one. The default minWorkers is 0, so the pool can scale down when the run is short. The singleThread key, when set, pins the run to one worker regardless of maxWorkers, and it is the correct replacement for the v3 poolOptions.threads.singleThread.
The file-level parallelism is a separate knob and is not removed. fileParallelism: false still means “run the test files sequentially” and is the right option when the files share a resource. It is orthogonal to maxWorkers: file parallelism decides whether files overlap, and maxWorkers decides how many workers exist to run them. A config that wants both a single worker and sequential files sets maxWorkers: 1 and leaves fileParallelism at its default.
// The two knobs are independent
export default defineConfig({
test: {
maxWorkers: 1, // one worker process total
fileParallelism: true, // files still queue behind that one worker
},
});
The CLI keeps --maxWorkers and --minWorkers as flags. The removed --threads family is gone, and the replacement for “do not use worker threads” is --pool=forks or --maxWorkers=1 depending on the intent. A CI job that pinned --threads=false in v3 migrates to --maxWorkers=1, which is the same effective limit with the current option name.
b. Reporter changes
The reporter set in v4 is default, verbose, dot, json, junit, tap, tap-flat, hanging-process, github-actions, and blob. The basic reporter that shipped in v1 is removed. Its output was a per-file summary with a pass count and a duration, which is what the default reporter now renders, so the two were duplicates. A config that names basic explicitly fails to resolve the reporter, and the fix is to name default or remove the reporters key and inherit the default.
// vitest.config.ts — v3 with the removed reporter
export default defineConfig({
test: {
reporters: ["basic"], // removed in v4; the run fails to resolve it
},
});
// vitest.config.ts — v4 equivalent
export default defineConfig({
test: {
reporters: ["default"], // the summary the basic reporter used to print
},
});
The default reporter’s output changed shape. In v3 the default printed one line per test file as the file finished, and the full test list needed verbose. In v4 the default prints a tree grouped by file with a pass/fail count and a duration, and the individual test names appear only when a test fails or when the reporter is verbose. The practical effect is that a green run is shorter and a red run is more focused: the failure output is attached to the file that produced it instead of being interleaved into a flat list.
// Force the per-test list in v4
export default defineConfig({
test: {
reporters: ["verbose"], // one line per test, not per file
},
});
The custom reporter contract is now awaited. The onFinished hook on a custom reporter may return a promise, and v4 waits for it before the process exits. A reporter that writes a file or uploads a summary in onFinished no longer needs a detached promise or a process hook to keep the event loop alive.
// A custom reporter whose cleanup is awaited in v4
import type { Reporter } from "vitest/reporters";
export default class UploadReporter implements Reporter {
async onFinished(files) {
// v4 awaits this promise before exiting
await uploadSummary(files);
}
}
The machine-readable reporters are unchanged in name but tightened in output. The json reporter emits the same top-level shape, and the junit reporter continues to map one test suite to one testsuite element. The github-actions reporter adds annotations for the failing tests, and the blob reporter is still the input to vitest merge-reports. A pipeline that parses the JSON output should re-run its schema test after the upgrade, because the per-file fields are where the changes land.
The --reporter flag can still be repeated, and when it is, the run prints each reporter’s output in sequence. The default reporter is added automatically when no reporter is named, and that automatic addition is unchanged. The difference is only which reporter the word basic used to resolve to.
c. Coverage defaults
The coverage section loses three options and changes what the default includes. The removed options are coverage.all, coverage.extension, and coverage.ignoreEmptyLines. The coverage.all toggle controlled whether files that no test imported were included in the report, and v4 replaces the toggle with the include and exclude patterns: a file is measured when it matches coverage.include and does not match coverage.exclude, whether or not a test imported it. The extension list is folded into include, because the extension list was only ever a coarse filter and include is the precise one.
// vitest.config.ts — v3 coverage block
export default defineConfig({
test: {
coverage: {
provider: "v8",
all: true, // measure files no test imported
extension: [".ts", ".tsx"], // coarse filter on the file extension
ignoreEmptyLines: true, // do not count blank lines
},
},
});
The v4 form keeps the provider and replaces the three removed keys with the pattern-based pair. A project that set all: true to measure untested files lists those files in include instead. A project that set ignoreEmptyLines: true removes the line, because the blank-line handling is now the default and is not configurable.
// vitest.config.ts — v4 coverage block
export default defineConfig({
test: {
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"], // what to measure, tested or not
exclude: ["src/**/*.test.{ts,tsx}"], // what to skip
},
},
});
The AST-aware remapping is now the only path. In v3 the engine could attribute coverage to the original TypeScript source through an experimental remap that was faster and more accurate than the legacy line-offset approach, and the experiment was gated behind coverage.experimentalAstAwareRemapping. v4 removes the gate and runs the remap unconditionally, so a monorepo with heavy transpilation sees coverage move closer to the source-level truth and occasionally see a previously-passing threshold cross.
// A threshold that may need re-reading after the remap change
export default defineConfig({
test: {
coverage: {
thresholds: {
lines: 80, // source-level; the remap can move this number
branches: 75,
functions: 80,
statements: 80,
},
},
},
});
The default threshold values are unchanged at zero, and the default reportsDirectory is still ./coverage. The default provider is still v8, and the istanbul provider is still available when the project needs its instrumentation. The important default change is inclusion: the report now describes the files the include pattern names, and a file that is missing from the report is a file the pattern did not match.
// The include pattern is the whole story in v4
export default defineConfig({
test: {
coverage: {
include: ["packages/*/src/**/*.ts"], // every package, tested or not
exclude: ["**/*.d.ts", "**/index.ts"], // the usual skips
},
},
});
Complete Example Session
// ============================================
// PART 1: THE V3 CONFIG, FOR REFERENCE
// ============================================
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
pool: "threads",
poolOptions: {
threads: { maxThreads: 4, minThreads: 1, singleThread: false },
},
reporters: ["basic"],
coverage: {
provider: "v8",
all: true,
extension: [".ts"],
ignoreEmptyLines: true,
},
},
});
// ============================================
// PART 2: THE WORKER MIGRATION
// ============================================
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
pool: "threads", // pool selection is unchanged
maxWorkers: 4, // was poolOptions.threads.maxThreads
minWorkers: 1, // was poolOptions.threads.minThreads
singleThread: false, // was poolOptions.threads.singleThread
},
});
// ============================================
// PART 3: THE FORKS MIGRATION
// ============================================
export default defineConfig({
test: {
pool: "forks", // the forks pool still exists
maxWorkers: 4, // was poolOptions.forks.maxForks
minWorkers: 1, // was poolOptions.forks.minForks
singleFork: true, // was poolOptions.forks.singleFork
},
});
// ============================================
// PART 4: THE CLI EQUIVALENT
// ============================================
// vitest run --maxWorkers=4 --minWorkers=1
// (the removed --threads flag is replaced by --maxWorkers)
// ============================================
// PART 5: FILE PARALLELISM STAYS SEPARATE
// ============================================
export default defineConfig({
test: {
maxWorkers: 1, // one worker process total
fileParallelism: false, // and the files run one at a time
},
});
// ============================================
// PART 6: THE REPORTER MIGRATION
// ============================================
export default defineConfig({
test: {
reporters: ["default"], // replaces the removed "basic"
},
});
// ============================================
// PART 7: THE VERBOSE REPORTER
// ============================================
export default defineConfig({
test: {
reporters: ["default", "json"], // summary to the terminal, JSON to a file
},
});
// ============================================
// PART 8: THE COVERAGE INCLUDE
// ============================================
export default defineConfig({
test: {
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"], // replaces coverage.all and extension
exclude: ["src/**/*.test.{ts,tsx}"],
},
},
});
// ============================================
// PART 9: THE COVERAGE THRESHOLDS
// ============================================
export default defineConfig({
test: {
coverage: {
thresholds: {
lines: 80, // source-level; the AST remap may move this
branches: 75,
functions: 80,
statements: 80,
},
},
},
});
// ============================================
// PART 10: THE FULL MIGRATED CONFIG
// ============================================
export default defineConfig({
test: {
pool: "threads",
maxWorkers: 4,
minWorkers: 1,
fileParallelism: true,
reporters: ["default"],
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
exclude: ["src/**/*.test.{ts,tsx}"],
thresholds: { lines: 80, branches: 75, functions: 80, statements: 80 },
},
},
});
The ten parts covered the v3 reference, the worker migration for the threads pool, the same migration for the forks pool, the CLI equivalent, the independence of file parallelism, the reporter rename, a multi-reporter setup, the coverage include, the thresholds, and the fully migrated file.
Quick Reference
Worker Option Mapping
| Vitest 3 | Vitest 4 |
|---|---|
poolOptions.threads.maxThreads | maxWorkers |
poolOptions.threads.minThreads | minWorkers |
poolOptions.threads.singleThread | singleThread |
poolOptions.forks.maxForks | maxWorkers |
poolOptions.forks.singleFork | singleFork |
poolOptions (whole object) | removed |
Reporter Set
| Reporter | Status |
|---|---|
default | Present, redesigned output |
verbose | Present, per-test lines |
basic | Removed |
dot | Present |
json | Present |
junit | Present |
Coverage Option Mapping
| Vitest 3 | Vitest 4 |
|---|---|
coverage.all | include / exclude |
coverage.extension | include |
coverage.ignoreEmptyLines | removed (default) |
coverage.experimentalAstAwareRemapping | removed (always on) |
Defaults After Migration
| Option | Default |
|---|---|
maxWorkers | os.availableParallelism() |
minWorkers | 0 |
pool | threads |
coverage.provider | v8 |
coverage.thresholds | all zero |
Best Practices
✅ Do This:
// Move the worker limit to the top level
maxWorkers: 4 // ✅
// Name the default reporter explicitly when migrating
reporters: ["default"] // ✅
// Express untested-file inclusion with a pattern
coverage: { include: ["src/**/*.ts"] } // ✅
// Keep file parallelism separate from the worker count
fileParallelism: false // ✅
// Use singleThread for a deterministic single-worker run
singleThread: true // ✅
// Pin the CLI flag to the current name
// vitest run --maxWorkers=4 // ✅
// Re-read thresholds after the AST remap change
thresholds: { lines: 80 } // ✅
❌ Don’t Do This:
// Leave the removed poolOptions object in place
poolOptions: { threads: { maxThreads: 4 } } // ❌
// Keep the removed basic reporter
reporters: ["basic"] // ❌
// Keep the removed coverage toggles
coverage: { all: true, extension: [".ts"] } // ❌
// Use the removed empty-line toggle
coverage: { ignoreEmptyLines: true } // ❌
// Assume maxWorkers also serializes the files
maxWorkers: 1 // fileParallelism is still true // ❌
// Use the removed --threads CLI flag
// vitest run --threads=false // ❌
// Trust the old threshold number after the upgrade
thresholds: { lines: 80 } // verify it still passes // ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| Config key silently ignored | Schema drops removed key | Move value to the v4 key |
Type error on poolOptions | Removed from the type | Delete the object, use top level |
| Reporter fails to resolve | basic is gone | Rename to default |
| Coverage drops after upgrade | all removed, include missing | Add the include pattern |
| Threshold suddenly fails | AST remap attributes lines differently | Re-check the threshold |
| One worker but slow files | fileParallelism still true | Set it false separately |
--threads unknown flag | CLI flag removed | Use --maxWorkers |
| Empty-line count changes | ignoreEmptyLines removed | Accept the new default |
Real-World Examples
1. The removed pool options
poolOptions: { threads: { maxThreads: 4 } } // v3 only
2. The top-level replacement
maxWorkers: 4; // applies to threads, forks, and vmThreads
3. The single-worker pin
singleThread: true; // one worker, any pool
4. The forks equivalent
pool: "forks", singleFork: true; // was poolOptions.forks.singleFork
5. The reporter rename
reporters: ["default"]; // was ["basic"]
6. The verbose reporter
reporters: ["verbose"]; // one line per test
7. The coverage include
coverage: { include: ["src/**/*.ts"] } // was all: true
8. The extension fold
coverage: { include: ["**/*.{ts,tsx}"] } // was extension: [".ts"]
9. The threshold recheck
thresholds: { lines: 80 } // verify after the remap change
10. The CLI flag
vitest run --maxWorkers=4 # replaces --threads=false
Visual
The poolOptions Collapse
┌──────────────────────────────────────────┐
│ VITEST 3 — poolOptions │
│ threads.maxThreads: 4 │
│ threads.minThreads: 1 │
│ threads.singleThread: false │
│ forks.maxForks: 4 │
│ │
│ VITEST 4 — top level │
│ maxWorkers: 4 │
│ minWorkers: 1 │
│ singleThread: false │
│ pool: 'threads' │
└──────────────────────────────────────────┘
The Reporter Set
┌──────────────────────────────────────────┐
│ KEPT │
│ default ──► tree, per-file summary │
│ verbose ──► one line per test │
│ dot ──► minimal progress │
│ json ──► machine readable │
│ │
│ REMOVED │
│ basic ──► use default instead │
└──────────────────────────────────────────┘
The Coverage Inclusion Flow
┌──────────────────────────────────────────┐
│ coverage.include pattern │
│ │ │
│ ▼ │
│ matches? ── yes ──► measure the file │
│ │ │ │
│ │ ▼ │
│ │ imported by a test? │
│ │ yes ──► count lines │
│ │ no ──► count zeros │
│ │ │
│ └── no ──► skip the file │
└──────────────────────────────────────────┘
The Migration Checklist
┌──────────────────────────────────────────┐
│ 1. poolOptions ──► maxWorkers │
│ 2. basic ──► default │
│ 3. all ──► include │
│ 4. extension ──► include │
│ 5. emptyLines ──► remove │
│ 6. remap flag ──► remove │
│ 7. run the suite │
│ 8. recheck thresholds │
└──────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| Release | Vitest 4 |
| Worker object | poolOptions removed |
| Worker keys | maxWorkers, minWorkers, singleThread |
| Fork keys | maxWorkers, minWorkers, singleFork |
| Reporter removed | basic |
| Reporter default | default |
| Coverage removed | all, extension, ignoreEmptyLines |
| Coverage remap | AST-aware, always on |
| Coverage inclusion | include / exclude |
| Pool selection | pool unchanged |
Key takeaways:
poolOptionsis gone. The worker limits aremaxWorkers,minWorkers,singleThread, andsingleForkat the top level, and the pool name is the only part that keeps its original key.maxWorkersis pool-independent. The same key governs the threads, forks, and vmThreads pools, so a project that switched pools no longer needs a second limit.fileParallelismis a separate knob. It decides whether files overlap, whilemaxWorkersdecides how many workers exist; setting one does not set the other.- The
basicreporter is removed. Its output is now thedefaultreporter’s output, and the rename is the whole migration. - The default reporter redesigned its output. A green run is a per-file tree with counts and durations; the per-test list is
verbose. - Coverage inclusion is pattern-based.
coverage.allandcoverage.extensionare replaced bycoverage.includeandcoverage.exclude, andignoreEmptyLinesis gone. - The AST remap is unconditional. The experimental flag was removed, and thresholds may need re-reading because the remap attributes lines to the source rather than the transpiled output.
- The migration is mechanical, not silent. A removed key does not keep working; it either fails to resolve, is dropped, or becomes a type error, and each one has a named replacement.
Remember: Vitest 4 is a consolidation release, and its breaking changes are all the same shape: a deprecated duplicate is deleted and the surviving key is named. The worker limits move from poolOptions to maxWorkers and friends, the basic reporter folds into default, and the coverage toggles fold into include and exclude with the AST remap always on. None of the replacements adds a new concept — each one is the surviving name for behaviour that already existed, so the migration is a search-and-rename followed by a threshold check.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!