vitest-dev/vitest · error · IncludeTaskLocationDisabledError
VITEST_INCLUDE_TASK_LOCATION_DISABLED
VITEST_INCLUDE_TASK_LOCATION_DISABLED
Error message
Received line number filters while `includeTaskLocation` option is disabled
What it means
Thrown as `IncludeTaskLocationDisabledError` (code `VITEST_INCLUDE_TASK_LOCATION_DISABLED`) from `globTestSpecifications` (specifications.ts:51) when a CLI/test filter contains a line number (e.g. `path/to/test.ts:42`) but the `includeTaskLocation` config option is disabled. Line-number filtering requires Vitest to retain source locations for every task, which is opt-in because of its overhead, so the combination is rejected up front.
Source
Thrown at packages/vitest/src/node/specifications.ts:51
}
public async getRelevantTestSpecifications(filters: string[] = []): Promise<TestSpecification[]> {
return this.filterTestsBySource(
await this.globTestSpecifications(filters),
)
}
public async globTestSpecifications(filters: string[] = []): Promise<TestSpecification[]> {
const files: TestSpecification[] = []
const dir = process.cwd()
const parsedFilters = filters.map(f => parseFilter(f))
// Require includeTaskLocation when a location filter is passed
if (
!this.vitest.config.includeTaskLocation
&& parsedFilters.some(f => f.lineNumber !== undefined)
) {
throw new IncludeTaskLocationDisabledError()
}
const testLines = groupFilters(parsedFilters.map(
f => ({ ...f, filename: resolve(dir, f.filename) }),
))
// Key is file and val specifies whether we have matched this file with testLocation
const testLocHasMatch: { [f: string]: boolean } = {}
await Promise.all(this.vitest.projects.map(async (project) => {
const { testFiles, typecheckTestFiles } = await project.globTestFiles(
parsedFilters.map(f => f.filename),
)
testFiles.forEach((file) => {
const lines = testLines[file]
testLocHasMatch[file] = true
View on GitHub (pinned to d568f8ce37)
Solutions
- Enable `includeTaskLocation: true` in the Vitest config when you want to use line-number filters.
- Drop the `:lineNumber` suffix from the filter if you don't need line-level filtering.
- Set the option via the `test` config key: `defineConfig({ test: { includeTaskLocation: true } })`.
Example fix
// before
export default defineConfig({ test: {} })
// vitest test/foo.test.ts:10 -> error
// after
export default defineConfig({ test: { includeTaskLocation: true } }) Defensive patterns
Strategy: validation
Validate before calling
const hasLineFilter = filters.some(f => /:\d+$/.test(f))
if (hasLineFilter && !config.includeTaskLocation) {
throw new Error('Enable test.includeTaskLocation to use line-number filters')
} Prevention
- Enable `includeTaskLocation: true` in configs meant for editor-driven line runs.
- Strip `:line` suffixes when running full suites if the option is off.
- Document the option wherever line filters are introduced.
When it happens
Trigger: Running `vitest test/foo.test.ts:10` without having set `includeTaskLocation: true`; passing a parsed location filter with a `lineNumber` while the config flag is off (the default).
Common situations: IDE/editor 'run test at cursor' commands that append `:line`; using line filters for the first time without enabling the option; copying a filter from docs without the required config.
Related errors
- VITEST_LOCATION_FILTER_FILE_NOT_FOUND
- "browser.instances" was set in the config, but the array is
- Vitest received --browser flag, but no project had a browser
- No projects matched the filter "${filter}".
- --shard <count> must be a smaller than count of test files.
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/fcdf47c3377d43e8.json.
Report an issue: GitHub.