{"record":{"id":"c2e20852c67d2647","repo":"mochajs/mocha","slug":"warning-warning-message","errorCode":null,"errorMessage":"Warning: ${warning.message}","messagePattern":"Warning: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/cli/collect-files.cjs","lineNumber":106,"sourceCode":"    ...fileArgs.map((filepath) => path.resolve(filepath)),\n    ...specFiles,\n  ];\n  debug(\"test files (in order): \", files);\n\n  if (!files.length) {\n    // give full message details when only 1 file is missing\n    const noneFoundMsg =\n      unmatchedSpecFiles.length === 1\n        ? `Error: No test files found: ${JSON.stringify(\n            unmatchedSpecFiles[0].pattern,\n          )}` // stringify to print escaped characters raw\n        : \"Error: No test files found\";\n    console.error(pc.red(noneFoundMsg));\n    process.exit(1);\n  } else {\n    // print messages as a warning\n    unmatchedSpecFiles.forEach((warning) => {\n      console.warn(pc.yellow(`Warning: ${warning.message}`));\n    });\n  }\n\n  return {\n    files,\n    unmatchedFiles,\n  };\n};\n","sourceCodeStart":88,"sourceCodeEnd":115,"githubUrl":"https://github.com/mochajs/mocha/blob/6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a/lib/cli/collect-files.cjs#L88-L115","documentation":"When mocha's file collector finds test files but also spec-file arguments that matched nothing, it treats each unmatched pattern as a warning: for each entry in `unmatchedSpecFiles` it prints `Warning: <message>` to stderr via console.warn. This is not a thrown exception but a diagnostic message indicating some of your file arguments/globs were ignored.","triggerScenarios":"Passing `mocha run path/to/spec.js` where the path does not exist or does not match anything, while other valid test files were still found; glob patterns with typos or wrong extensions among otherwise valid args.","commonSituations":"Renamed or deleted spec files still referenced on the CLI or in .mocharc config; case-sensitivity mismatches on case-sensitive filesystems; globs written for a different directory layout after a repo restructure.","solutions":["Read each warning's message to identify which pattern matched nothing","Fix or remove the stale path/glob from the CLI args, .mocharc file, or npm script","Verify the file exists relative to the cwd mocha runs in (`ls <pattern>` or expand the glob yourself)","Enable/inspect `unmatchedFiles` in programmatic usage to handle it explicitly"],"exampleFix":"// before\n\"test\": \"mocha test/unit.spec.js test/does-not-exist.spec.js\"\n// after\n\"test\": \"mocha test/unit.spec.js test/integration.spec.js\"","handlingStrategy":"validation","validationCode":"const glob = require('glob');\nconst missing = patterns.filter((p) => glob.sync(p).length === 0);\nif (missing.length) console.warn('Patterns matching nothing:', missing);","typeGuard":"const hasMatches = (pattern) => require('glob').sync(pattern).length > 0;","tryCatchPattern":"try {\n  const result = collectFiles(args);\n  result.unmatchedFiles.forEach((f) => console.warn('No match for:', f));\n} catch (err) {\n  // only fatal when no files at all were found\n  console.error(err.message);\n  process.exitCode = 1;\n}","preventionTips":["Keep CLI/config file lists in sync with the repo layout","Prefer globs over explicit per-file lists to avoid stale entries","Run from the directory your relative paths assume","Treat unmatchedFiles output as CI noise to fix, not ignore"],"tags":["cli","file-glob","warning"],"backgroundTag":"no-files-matched-pattern","analyzedSha":"6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a","analyzedAt":"2026-09-01T03:41:47.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}