{"record":{"id":"71df7a0a88df2c45","repo":"avajs/ava","slug":"the-files-configuration-must-be-an-array-contain","errorCode":null,"errorMessage":"The ’files’ configuration must be an array containing glob patterns.","messagePattern":"The ’files’ configuration must be an array containing glob patterns\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/globs.js","lineNumber":37,"sourceCode":"\tnormalizePattern,\n\tdefaultIgnorePatterns,\n\thasExtension,\n\tnormalizeFileForMatching,\n\tnormalizePatterns,\n} from './glob-helpers.js';\n\nconst defaultIgnoredByWatcherPatterns = [\n\t'**/*.snap.md', // No need to rerun tests when the Markdown files change.\n\t'**/*.tsbuildinfo', // No need to rerun tests when TypeScript build info files change.\n\t'ava.config.js', // Config is not reloaded so avoid rerunning tests when it changes.\n\t'ava.config.mjs', // Config is not reloaded so avoid rerunning tests when it changes.\n];\n\nconst buildExtensionPattern = extensions => extensions.length === 1 ? extensions[0] : `{${extensions.join(',')}}`;\n\nexport function normalizeGlobs({extensions, files: filePatterns, ignoredByWatcher: ignoredByWatcherPatterns, providers}) {\n\tif (filePatterns !== undefined && (!Array.isArray(filePatterns) || filePatterns.length === 0)) {\n\t\tthrow new Error('The ’files’ configuration must be an array containing glob patterns.');\n\t}\n\n\tif (ignoredByWatcherPatterns !== undefined && (!Array.isArray(ignoredByWatcherPatterns) || ignoredByWatcherPatterns.length === 0)) {\n\t\tthrow new Error('The ’watchMode.ignoreChanges’ configuration must be an array containing glob patterns.');\n\t}\n\n\tconst extensionPattern = buildExtensionPattern(extensions);\n\tconst defaultTestPatterns = [\n\t\t`test.${extensionPattern}`,\n\t\t`{src,source}/test.${extensionPattern}`,\n\t\t`**/__tests__/**/*.${extensionPattern}`,\n\t\t`**/*.spec.${extensionPattern}`,\n\t\t`**/*.test.${extensionPattern}`,\n\t\t`**/test-*.${extensionPattern}`,\n\t\t`**/test/**/*.${extensionPattern}`,\n\t\t`**/tests/**/*.${extensionPattern}`,\n\t\t'!**/__tests__/**/__{helper,fixture}?(s)__/**/*',\n\t\t'!**/test?(s)/**/{helper,fixture}?(s)/**/*',","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/globs.js#L19-L55","documentation":"The `files` configuration selects which files AVA runs as tests; it must be a non-empty array of glob pattern strings. normalizeGlobs throws if `files` is defined but is not an array or is an empty array.","triggerScenarios":"Setting `files: 'test/**/*.js'` (a bare string instead of an array), `files: []`, or `files: null` with files defined, in ava.config.js/package.json or the programmatic API.","commonSituations":"Copying CLI glob strings directly into config without wrapping in an array; an empty array produced by filtered/generated config; editing package.json so files becomes an empty list.","solutions":["Wrap the pattern in an array: `files: ['test/**/*.test.js']`.","Ensure the array is non-empty; remove code that yields `files: []`.","If building patterns dynamically, validate length > 0 before assigning.","Fall back to AVA's defaults by omitting `files` entirely rather than passing an empty array."],"exampleFix":"// before\nexport default {files: 'test/**/*.js'};\n// after\nexport default {files: ['test/**/*.js']};","handlingStrategy":"validation","validationCode":"if (config.files !== undefined && (!Array.isArray(config.files) || config.files.length === 0)) {\n  throw new TypeError('files must be a non-empty array of glob strings');\n}","typeGuard":"const isValidFiles = v => v === undefined || (Array.isArray(v) && v.length > 0 && v.every(p => typeof p === 'string'));","tryCatchPattern":"try {\n  await run();\n} catch (err) {\n  if (err.message.includes('’files’ configuration must be an array')) {\n    console.error('Use files: [\\'test/**/*.js\\'] — an array, non-empty');\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Wrap globs in arrays in all AVA config sources.","Never assign an empty files array; omit the key to use defaults.","Check generated configs for empty-array results after filtering.","Add a config smoke test in CI that starts AVA with --list."],"tags":["configuration","validation","globs"],"backgroundTag":"schema-validation-failed","analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}