{"record":{"id":"6328eb574ca688ab","repo":"microsoft/TypeScript","slug":"no-test-file-named-indexorname-exists-availa","errorCode":null,"errorMessage":"No test file named \"${indexOrName}\" exists. Available file names are: ${availableNames.join(\", \")}","messagePattern":"No test file named \"(.+?)\" exists\\. Available file names are: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/fourslashImpl.ts","lineNumber":4436,"sourceCode":"                this.currentCaretPosition,\r\n            ).line,\r\n        );\r\n    }\r\n\r\n    private findFile(indexOrName: string | number): FourSlashFile {\r\n        if (typeof indexOrName === \"number\") {\r\n            const index = indexOrName;\r\n            if (index >= this.testData.files.length) {\r\n                throw new Error(`File index (${index}) in openFile was out of range. There are only ${this.testData.files.length} files in this test.`);\r\n            }\r\n            else {\r\n                return this.testData.files[index];\r\n            }\r\n        }\r\n        else if (ts.isString(indexOrName)) {\r\n            const { file, availableNames } = this.tryFindFileWorker(indexOrName);\r\n            if (!file) {\r\n                throw new Error(`No test file named \"${indexOrName}\" exists. Available file names are: ${availableNames.join(\", \")}`);\r\n            }\r\n            return file;\r\n        }\r\n        else {\r\n            return ts.Debug.assertNever(indexOrName);\r\n        }\r\n    }\r\n\r\n    private tryFindFileWorker(name: string): { readonly file: FourSlashFile | undefined; readonly availableNames: readonly string[]; } {\r\n        name = ts.normalizePath(name);\r\n        // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName\r\n        name = name.includes(\"/\") ? name : (this.basePath + \"/\" + name);\r\n\r\n        const availableNames: string[] = [];\r\n        const file = ts.forEach(this.testData.files, file => {\r\n            const fn = ts.normalizePath(file.fileName);\r\n            if (fn) {\r\n                if (fn === name) {\r","sourceCodeStart":4418,"sourceCodeEnd":4454,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/fourslashImpl.ts#L4418-L4454","documentation":"Thrown by findFile when the string argument to openFile/goTo.file does not match any test file name. The message lists all available file names so the author can correct the reference. Matching is done via tryFindFileWorker after normalising the path.","triggerScenarios":"Calling goTo.file(\"missing.ts\") where no file with that name (or relative path) was declared in the fourslash test data. tryFindFileWorker normalises the name and, if it has no slash, prepends basePath before searching.","commonSituations":"Typo in the file name, referencing a file that was renamed/removed, or using a full path when the test stores files under a relative name. Also happens when the name needs a leading slash or directory prefix.","solutions":["Read the available file names from the error message and copy the exact spelling/path of the intended file.","If the file should exist, add it to the test using the multi-file fourslash syntax (@FileName or a new //// block).","If you used a bare name, try the path relative to basePath, or vice versa, since matching depends on whether the name contains a slash."],"exampleFix":"// before\ngoTo.file(\"moduel.ts\");\n// after — match an available name from the error output\ngoTo.file(\"module.ts\");","handlingStrategy":"validation","validationCode":"function resolveFileName(state: FourSlashTestState, name: string) {\n    const known = state.testData.files.map(f => f.fileName);\n    if (!known.some(n => n.endsWith(name) || n === name)) {\n        throw new Error(`'${name}' not in: ${known.join(\", \")}`);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy file names from the test's //// and @FileName declarations to avoid typos.","Use consistent path conventions (with or without leading slash) matching how files are declared."],"tags":["fourslash","file-management","name-mismatch"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}