{"record":{"id":"472b1db1cc73eb93","repo":"vitest-dev/vitest","slug":"vitest-location-filter-file-not-found","errorCode":"VITEST_LOCATION_FILTER_FILE_NOT_FOUND","errorMessage":"Couldn't find file ${filename}. Note when specifying the test location you have to specify the full test filename.","messagePattern":"Couldn't find file (.+?)\\. Note when specifying the test location you have to specify the full test filename\\.","errorType":"exception","errorClass":"LocationFilterFileNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/specifications.ts","lineNumber":87,"sourceCode":"        testLocHasMatch[file] = true\n\n        const spec = project.createSpecification(file, lines)\n        this.ensureSpecificationCached(spec)\n        files.push(spec)\n      })\n      typecheckTestFiles.forEach((file) => {\n        const lines = testLines[file]\n        testLocHasMatch[file] = true\n\n        const spec = project.createSpecification(file, lines, 'typescript')\n        this.ensureSpecificationCached(spec)\n        files.push(spec)\n      })\n    }))\n\n    Object.entries(testLines).forEach(([filepath, loc]) => {\n      if (loc.length !== 0 && !testLocHasMatch[filepath]) {\n        throw new LocationFilterFileNotFoundError(\n          relative(dir, filepath),\n        )\n      }\n    })\n\n    return files\n  }\n\n  public clearCache(moduleId?: string): void {\n    if (moduleId) {\n      this._cachedSpecs.delete(moduleId)\n    }\n    else {\n      this._cachedSpecs.clear()\n    }\n  }\n\n  private getCachedSpecifications(moduleId: string): TestSpecification[] | undefined {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/specifications.ts#L69-L105","documentation":"A location (line-number) filter references a file that no project's test globs include. Vitest validates this after globbing so a typo'd filename with a `:line` filter doesn't silently run nothing. The path must be the full test filename as resolved from `process.cwd()`.","triggerScenarios":"`vitest tests/foo.test.ts:10` where `tests/foo.test.ts` is not in any project's `testFiles`/`typecheckTestFiles`; the entry in `testLines` has no matching `testLocHasMatch`.","commonSituations":"Relative-path mismatch (cwd vs. root); file renamed; pointing at a source file instead of the test file; the file isn't covered by any project's `include` glob.","solutions":["Use the full, exact test filename as it appears in Vitest's normal output.","Confirm the file is matched by some project's `include` glob (run without the `:line` filter to see it discovered).","Run from the same working directory Vitest resolves filters against (`process.cwd()`)."],"exampleFix":"# before: file path is relative to a different cwd / not matched\nvitest foo.test.ts:10   # VITEST_LOCATION_FILTER_FILE_NOT_FOUND\n\n# after: use the full path as shown in vitest output\nvitest tests/unit/foo.test.ts:10","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nfunction assertLocationFilterFileExists(cwd: string, filters: string[]) {\n  for (const f of filters) {\n    const m = f.match(/^(.*):\\d+$/)\n    if (!m) continue\n    const file = resolve(cwd, m[1])\n    if (!existsSync(file)) {\n      throw new Error(`Location filter file not found: ${m[1]} (resolved to ${file}). Use the full test path.`)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute or cwd-relative test paths exactly as Vitest prints them.","Run the file without the `:line` filter first to confirm it is discovered."],"tags":["cli","filter"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}