{"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":51,"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":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/specifications.ts#L33-L69","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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 } })`."],"exampleFix":"// before\nexport default defineConfig({ test: {} })\n// vitest test/foo.test.ts:10  -> error\n\n// after\nexport default defineConfig({ test: { includeTaskLocation: true } })","handlingStrategy":"validation","validationCode":"const hasLineFilter = filters.some(f => /:\\d+$/.test(f))\nif (hasLineFilter && !config.includeTaskLocation) {\n  throw new Error('Enable test.includeTaskLocation to use line-number filters')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["config","filters","location","cli"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}