{"record":{"id":"fcdf47c3377d43e8","repo":"vitest-dev/vitest","slug":"vitest-include-task-location-disabled","errorCode":"VITEST_INCLUDE_TASK_LOCATION_DISABLED","errorMessage":"Received line number filters while `includeTaskLocation` option is disabled","messagePattern":"Received line number filters while `includeTaskLocation` option is disabled","errorType":"exception","errorClass":"IncludeTaskLocationDisabledError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/specifications.ts","lineNumber":52,"sourceCode":"  }\n\n  public async getRelevantTestSpecifications(filters: string[] = []): Promise<TestSpecification[]> {\n    return this.filterTestsBySource(\n      await this.globTestSpecifications(filters),\n    )\n  }\n\n  public async globTestSpecifications(filters: string[] = []): Promise<TestSpecification[]> {\n    const files: TestSpecification[] = []\n    const dir = process.cwd()\n    const parsedFilters = filters.map(f => parseFilter(f))\n\n    // Require includeTaskLocation when a location filter is passed\n    if (\n      !this.vitest.config.includeTaskLocation\n      && parsedFilters.some(f => f.lineNumber !== undefined)\n    ) {\n      throw new IncludeTaskLocationDisabledError()\n    }\n\n    const testLines = groupFilters(parsedFilters.map(\n      f => ({ ...f, filename: resolve(dir, f.filename) }),\n    ))\n\n    // Key is file and val specifies whether we have matched this file with testLocation\n    const testLocHasMatch: { [f: string]: boolean } = {}\n\n    await Promise.all(this.vitest.projects.map(async (project) => {\n      const { testFiles, typecheckTestFiles } = await project.globTestFiles(\n        parsedFilters.map(f => f.filename),\n      )\n\n      testFiles.forEach((file) => {\n        const lines = testLines[file]\n        testLocHasMatch[file] = true\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/specifications.ts#L34-L70","documentation":"Line-number location filters (e.g. `vitest foo.test.ts:42`) require Vitest to have recorded each test's source location at collection time, which only happens when `includeTaskLocation: true`. Passing a `file:line` filter while the option is off throws `IncludeTaskLocationDisabledError` so the filter isn't silently ignored.","triggerScenarios":"Any filter parsed by `parseFilter` that yields `lineNumber !== undefined`, while `vitest.config.includeTaskLocation` is falsy. Triggered via CLI (`file:line`) or programmatic filters passed to `globTestSpecifications`.","commonSituations":"New users trying `vitest foo.test.ts:10` with default config; programmatic API passing `{ filename, lineNumber }` filters; migration from a tool where line filters work by default.","solutions":["Enable `includeTaskLocation: true` in the Vitest config (it has a small collection-time cost).","Or drop the `:lineNumber` suffix and run the whole file instead.","For programmatic use, gate line filters on the config value before passing them."],"exampleFix":"// before\nexport default defineConfig({ test: {} })\n// vitest foo.test.ts:10  ->  VITEST_INCLUDE_TASK_LOCATION_DISABLED\n\n// after\nexport default defineConfig({\n  test: { includeTaskLocation: true },\n})\n// vitest foo.test.ts:10  ->  runs only the test at line 10","handlingStrategy":"validation","validationCode":"function assertLineFiltersAllowed(config: { includeTaskLocation?: boolean }, filters: string[]) {\n  const hasLine = filters.some(f => /:\\d+$/.test(f))\n  if (hasLine && !config.includeTaskLocation) {\n    throw new Error('Line filters require includeTaskLocation: true. Enable it or drop the :line suffix.')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set `includeTaskLocation: true` in any config where you intend to use `file:line` filters.","Strip `:line` suffixes programmatically when the option is off."],"tags":["cli","filter","config"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}