vitest-dev/vitest · error
Missing configurationFile. The…
Error message
Missing configurationFile. The "coverage.thresholds.autoUpdate" can only be enabled when configuration file is used.
What it means
coverage.thresholds.autoUpdate rewrites thresholds back into the config file on disk, so it requires an actual configFile. If vite.config.configFile is undefined (inline config, CLI-only, or programmatic createVitest without configFile), there is nothing to rewrite and it throws.
Solutions
- Create a vitest.config.ts / vite.config.ts so vite.config.configFile resolves.
- Disable coverage.thresholds.autoUpdate when no config file is available.
- Pass configFile explicitly when using the programmatic API.
Example fix
// before
await createVitest('test', {
config: { coverage: { thresholds: { autoUpdate: true, lines: 80 } } }
})
// after - create vitest.config.ts, then:
await createVitest('test', {
configFile: path.resolve('vitest.config.ts')
}) Defensive patterns
Strategy: validation
Validate before calling
function hasConfigFile(vitest) {
return typeof vitest.vite.config.configFile === 'string'
}
// before enabling autoUpdate: if (!hasConfigFile(vitest)) disable autoUpdate or create config Prevention
- Create a vitest.config.ts whenever you enable coverage.thresholds.autoUpdate.
- When using the programmatic API, pass configFile explicitly.
- Disable autoUpdate for ad-hoc / inline-config runs.
When it happens
Trigger: Enabling coverage.thresholds.autoUpdate: true while running with no on-disk config file (inline config, programmatic API without configFile, or a run that resolved config from package.json/CLI only).
Common situations: Programmatic usage of createVitest; repos that use package.json or inline config; CI flag added without a config file present.
Related errors
- ${error instanceof Error ? error.message : String(error)}
- Expected config.test.coverage.thresholds to be an object
- Failed to update coverage thresholds. Configuration file is…
- Unable to parse thresholds from configuration file
- Cannot parse ' ' because "module.stripTypeScriptTypes" is…
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/3233b505db8f39b2.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/node/coverage.ts:409
(coverageMap as CoverageMap) || this.createCoverageMap(),
allTestsRun,
)
// In watch mode we need to preserve the previous results if cleanOnRerun is disabled
const keepResults = !this.options.cleanOnRerun && this.ctx.config.watch
if (!keepResults) {
await this.cleanAfterRun()
}
}
async reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void> {
const resolvedThresholds = this.resolveThresholds(coverageMap)
this.checkThresholds(resolvedThresholds)
if (this.options.thresholds?.autoUpdate && allTestsRun) {
if (!this.ctx.vite.config.configFile) {
throw new Error(
'Missing configurationFile. The "coverage.thresholds.autoUpdate" can only be enabled when configuration file is used.',
)
}
const configFilePath = this.ctx.vite.config.configFile
const configModule = await this.parseConfigModule(configFilePath)
await this.updateThresholds({
thresholds: resolvedThresholds,
configurationFile: configModule,
onUpdate: () =>
writeFileSync(
configFilePath,
configModule.generate().code.replace(this.autoUpdateMarker, ''),
'utf-8',
),
})View on GitHub (pinned to 1fa9837ec2)