{"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":86,"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":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/specifications.ts#L68-L104","documentation":"Thrown as `LocationFilterFileNotFoundError` (code `VITEST_LOCATION_FILTER_FILE_NOT_FOUND`) from `globTestSpecifications` (specifications.ts:86) when a location filter specifies a file that no project's test glob matched. After globbing test files for every project, Vitest checks each requested location file; if a requested file (with non-empty line filters) was never matched, it reports the filename so the user knows the path didn't resolve to a known test file.","triggerScenarios":"Passing `vitest ./src/foo.test.ts:5` where `foo.test.ts` is not under any project's `include` glob or is outside the project root; using a relative path that doesn't resolve against `process.cwd()`; a typo in the test filename; the file exists but isn't considered a test file by any project.","commonSituations":"Wrong working directory; `include` pattern excludes the file; filename typo; referencing a file that lives in a different project not enabled in this run.","solutions":["Use the full, correct test filename relative to the cwd (or absolute).","Check the project's `include`/`exclude` globs to confirm the file is treated as a test.","Run from the directory the test path is relative to, or pass an absolute path.","Ensure at least one enabled project's test glob matches the file."],"exampleFix":"# before\nvitest src/wrong-name.test.ts:10\n# after\nvitest src/utils/calc.test.ts:10","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nconst file = resolve(process.cwd(), userFilter.replace(/:\\d+$/, ''))\nif (!existsSync(file)) throw new Error(`Test file not found: ${file}`)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths or run from the directory the relative test path is rooted at.","Confirm the file matches at least one project's `include` glob.","Double-check filenames for typos before running."],"tags":["filters","location","cli","filesystem"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}