microsoft/TypeScript · error · Error

New baseline created at ${IO.joinPath("tests", "baselines",

Error message

New baseline created at ${IO.joinPath("tests", "baselines", "local", relativeFileName)}

What it means

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.

Source

Thrown at src/harness/harnessIO.ts:1490

            IO.deleteFile(actualFileName);
        }

        const encodedActual = Utils.encodeString(actual);
        if (expected !== encodedActual) {
            if (actual === noContent) {
                IO.writeFile(actualFileName + ".delete", "");
            }
            else {
                IO.writeFile(actualFileName, encodedActual);
            }
            const errorMessage = getBaselineFileChangedErrorMessage(relativeFileName);
            if (opts && opts.PrintDiff) {
                const patch = Diff.createTwoFilesPatch("Expected", "Actual", expected, actual, "The current baseline", "The new version");
                throw new Error(`${errorMessage}${ts.ForegroundColorEscapeSequences.Grey}\n\n${patch}`);
            }
            else {
                if (!IO.fileExists(expected)) {
                    throw new Error(`New baseline created at ${IO.joinPath("tests", "baselines", "local", relativeFileName)}`);
                }
                else {
                    throw new Error(errorMessage);
                }
            }
        }
    }

    function getBaselineFileChangedErrorMessage(relativeFileName: string): string {
        return `The baseline file ${relativeFileName} has changed. (Run "hereby baseline-accept" if the new baseline is correct.)`;
    }

    export function runBaseline(relativeFileName: string, actual: string | null, opts?: BaselineOptions): void { // eslint-disable-line no-restricted-syntax
        const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
        if (actual === undefined) {
            throw new Error('The generated content was "undefined". Return "null" if no baselining is required."');
        }
        const comparison = compareToBaseline(actual, relativeFileName, opts);

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Inspect the generated tests/baselines/local/<file> to confirm the output is correct.
  2. Run `hereby baseline-accept` to create the reference baseline from the local copy.
  3. Commit the new reference file alongside the test that introduced it.
  4. If the file should not be baselined, adjust the test's baseline name/extension so it is not produced.

Example fix

# before — new test has no reference yet
$ hereby test-compiler
Error: New baseline created at tests/baselines/local/...

# after — accept and commit
$ hereby baseline-accept
$ git add tests/baselines/reference/...
$ git commit
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: confirm a reference baseline exists; if not, mark the test as creating one.
const referenceExists = IO.fileExists(referencePath);
if (!referenceExists) {
  console.warn(`First-time baseline will be created at tests/baselines/local/${relativeFileName}`);
}

Try / catch

try {
  runBaseline(relativeFileName, actual);
} catch (e) {
  if (e.message.startsWith('New baseline created at')) {
    // expected for new tests — record and continue, accept later
    pendingNewBaselines.push(relativeFileName);
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/13e03ab2d004da9a. Report an issue: GitHub.