{"record":{"id":"13e03ab2d004da9a","repo":"microsoft/TypeScript","slug":"new-baseline-created-at-io-joinpath-tests-ba","errorCode":null,"errorMessage":"New baseline created at ${IO.joinPath(\"tests\", \"baselines\", \"local\", relativeFileName)}","messagePattern":"New baseline created at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/harnessIO.ts","lineNumber":1490,"sourceCode":"            IO.deleteFile(actualFileName);\r\n        }\r\n\r\n        const encodedActual = Utils.encodeString(actual);\r\n        if (expected !== encodedActual) {\r\n            if (actual === noContent) {\r\n                IO.writeFile(actualFileName + \".delete\", \"\");\r\n            }\r\n            else {\r\n                IO.writeFile(actualFileName, encodedActual);\r\n            }\r\n            const errorMessage = getBaselineFileChangedErrorMessage(relativeFileName);\r\n            if (opts && opts.PrintDiff) {\r\n                const patch = Diff.createTwoFilesPatch(\"Expected\", \"Actual\", expected, actual, \"The current baseline\", \"The new version\");\r\n                throw new Error(`${errorMessage}${ts.ForegroundColorEscapeSequences.Grey}\\n\\n${patch}`);\r\n            }\r\n            else {\r\n                if (!IO.fileExists(expected)) {\r\n                    throw new Error(`New baseline created at ${IO.joinPath(\"tests\", \"baselines\", \"local\", relativeFileName)}`);\r\n                }\r\n                else {\r\n                    throw new Error(errorMessage);\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    function getBaselineFileChangedErrorMessage(relativeFileName: string): string {\r\n        return `The baseline file ${relativeFileName} has changed. (Run \"hereby baseline-accept\" if the new baseline is correct.)`;\r\n    }\r\n\r\n    export function runBaseline(relativeFileName: string, actual: string | null, opts?: BaselineOptions): void { // eslint-disable-line no-restricted-syntax\r\n        const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);\r\n        if (actual === undefined) {\r\n            throw new Error('The generated content was \"undefined\". Return \"null\" if no baselining is required.\"');\r\n        }\r\n        const comparison = compareToBaseline(actual, relativeFileName, opts);\r","sourceCodeStart":1472,"sourceCodeEnd":1508,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/harnessIO.ts#L1472-L1508","documentation":"Thrown by writeComparison (harnessIO.ts:1490) in the non-PrintDiff branch when actual output differs from expected AND the expected reference file does not exist on disk (IO.fileExists(expected) is false). This is the first-time baseline case: the harness wrote a new local baseline and reports where it landed.","triggerScenarios":"A new test (or a test whose output filename changed) produces content for which there is no corresponding file under tests/baselines/reference. The harness creates tests/baselines/local/<relativeFileName> and throws so the run is visibly red until the baseline is accepted.","commonSituations":"Adding a brand-new test; renaming an output artifact; a compiler change that emits a new auxiliary file (e.g. a new .tsbuildinfo or source map) that had no prior baseline.","solutions":["Inspect the generated tests/baselines/local/<file> to confirm the output is correct.","Run `hereby baseline-accept` to create the reference baseline from the local copy.","Commit the new reference file alongside the test that introduced it.","If the file should not be baselined, adjust the test's baseline name/extension so it is not produced."],"exampleFix":"# before — new test has no reference yet\n$ hereby test-compiler\nError: New baseline created at tests/baselines/local/...\n\n# after — accept and commit\n$ hereby baseline-accept\n$ git add tests/baselines/reference/...\n$ git commit","handlingStrategy":"validation","validationCode":"// Pre-flight: confirm a reference baseline exists; if not, mark the test as creating one.\nconst referenceExists = IO.fileExists(referencePath);\nif (!referenceExists) {\n  console.warn(`First-time baseline will be created at tests/baselines/local/${relativeFileName}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runBaseline(relativeFileName, actual);\n} catch (e) {\n  if (e.message.startsWith('New baseline created at')) {\n    // expected for new tests — record and continue, accept later\n    pendingNewBaselines.push(relativeFileName);\n    return;\n  }\n  throw e;\n}","preventionTips":["When adding a new test, immediately run `hereby baseline-accept` and commit the reference.","Name output files deterministically so renames do not create stray new baselines.","In CI, fail if any tests/baselines/local files remain after baseline-accept."],"tags":["test-harness","baseline","first-time","accept"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}