{"record":{"id":"8650131dd6757c04","repo":"vitest-dev/vitest","slug":"vitest-files-not-found","errorCode":"VITEST_FILES_NOT_FOUND","errorMessage":"No test files found","messagePattern":"No test files found","errorType":"exception","errorClass":"FilesNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/core.ts","lineNumber":866,"sourceCode":"        specifications = specifications.filter(({ testModule }) => {\n          return !testModule || testModule.task.mode !== 'skip'\n        })\n      }\n\n      // if run with --changed, don't exit if no tests are found\n      if (!specifications.length) {\n        await this._traces.$('vitest.test_run', async () => {\n          await this._testRun.start([])\n          await this.coverageProvider?.onTestRunStart?.()\n          const coverage = await this.coverageProvider?.generateCoverage?.({ allTestsRun: true })\n\n          await this._testRun.end([], [], coverage)\n          // Report coverage for uncovered files\n          await this.reportCoverage(coverage, true)\n        })\n\n        if (!this.config.watch || !(this.config.changed || this.config.related?.length)) {\n          throw new FilesNotFoundError()\n        }\n      }\n\n      let testModules: TestRunResult = {\n        testModules: [],\n        unhandledErrors: [],\n      }\n\n      if (specifications.length) {\n        // populate once, update cache on watch\n        await this.cache.stats.populateStats(this.config.root, specifications)\n\n        testModules = await this.runFiles(specifications, true)\n      }\n\n      if (this.config.watch) {\n        await this.report('onWatcherStart')\n      }","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/core.ts#L848-L884","documentation":"FilesNotFoundError (code VITEST_FILES_NOT_FOUND) is thrown when no test specifications are produced and the run is not a watch-with-changed/related trigger. It is Vitest's canonical 'no test files found' error: nothing matched the include/glob/filter inputs. Suppressed only in watch mode when --changed or --related is also set.","triggerScenarios":"Running Vitest where specifications.length === 0 AND not (config.watch && (config.changed || config.related?.length)). Caused by include globs matching zero files, wrong --root/cwd, or CLI file filters that match nothing.","commonSituations":"Wrong working directory; glob excludes everything; renamed test files; a typo'd filter arg; fresh repo with no tests; CI running in a subdirectory.","solutions":["Check config.include actually matches files: list the resolved globs.","Verify --root / current working directory is the project root.","Remove overly restrictive CLI filters (e.g. a misspelled path).","Pass --pass-with-no-tests (or set passWithNoTests: true) if an empty run is acceptable.","If using --watch with --changed/--related, that path suppresses the throw legitimately."],"exampleFix":"// before - config with overly narrow include\nexport default defineConfig({ test: { include: ['src/**/*.spec.ts'] } })\n\n// after\nexport default defineConfig({\n  test: { include: ['test/**/*.test.ts', 'src/**/*.spec.ts'] }\n})","handlingStrategy":"validation","validationCode":"import { glob } from 'tinyglobby'\nasync function hasMatchedTests(config) {\n  const files = await glob(config.include, { cwd: config.root, ignore: config.exclude })\n  return files.length > 0\n}\n// before run: if (!await hasMatchedTests(config)) set passWithNoTests or fix globs","typeGuard":null,"tryCatchPattern":"try {\n  await vitest.start()\n} catch (e) {\n  if (e.code === 'VITEST_FILES_NOT_FOUND') {\n    // log, fix include/root, or set passWithNoTests and retry\n  } else throw e\n}","preventionTips":["Set passWithNoTests: true when an empty run is acceptable (e.g. filtered CI jobs).","Validate include globs against the actual test directory before running.","Confirm --root / cwd; run with --no-color --reporter=verbose to see resolved patterns."],"tags":["file-resolution","glob","no-tests"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}