microsoft/TypeScript · error · Error
verifyFileContent in file '${fileName}' failed:\n${showTextD
Error message
verifyFileContent in file '${fileName}' failed:\n${showTextDiff(text, actual)} What it means
Assertion failure in the Fourslash harness. `verifyFileContent(fileName, text)` (reached via `verifyCurrentFileContent`) compares the full on-disk-in-memory content of `fileName` against `text`; on mismatch it throws an `Error` whose message runs both texts through `showTextDiff`. Like 38, this is test-only.
Source
Thrown at src/harness/fourslashImpl.ts:3049
this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
}
}
public verifyCurrentLineContent(text: string): void {
const actual = this.getCurrentLineContent();
if (actual !== text) {
throw new Error("verifyCurrentLineContent\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
}
}
public verifyCurrentFileContent(text: string): void {
this.verifyFileContent(this.activeFile.fileName, text);
}
private verifyFileContent(fileName: string, text: string) {
const actual = this.getFileContent(fileName);
if (actual !== text) {
throw new Error(`verifyFileContent in file '${fileName}' failed:\n${showTextDiff(text, actual)}`);
}
}
public verifyFormatDocumentChangesNothing(): void {
const { fileName } = this.activeFile;
const before = this.getFileContent(fileName);
this.formatDocument();
this.verifyFileContent(fileName, before);
}
public verifyTextAtCaretIs(text: string): void {
const actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length);
if (actual !== text) {
throw new Error("verifyTextAtCaretIs\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
}
}
public verifyCurrentNameOrDottedNameSpanText(text: string): undefined {
View on GitHub (pinned to b465fdbfe1)
Solutions
- Apply the diff from the failure message to the expected string.
- Re-check that previous marker positioning put the action on the intended location.
- Match line endings and trailing newline exactly (`showTextDiff` is whitespace-sensitive).
- If the new output is the intended behavior, update the baseline; otherwise fix the feature.
Example fix
// before
fourshaft.verifyCurrentFileContent("const a = 1;");
// after (copy from the failure's actual block)
fourshaft.verifyCurrentFileContent("const a = 1;\nconst b = 2;\n"); Defensive patterns
Strategy: validation
Prevention
- Refresh Fourslash baselines from the reported `actual` block.
- Watch for line-ending/trailing-newline mismatches when copying expected text.
- After behavioral changes, run the full Fourslash suite and triage every `verifyFileContent` failure.
When it happens
Trigger: A Fourslash test where the expected file content diverges from what the language service/compiler produced after edits, completions, refactors, or formatting. Triggered by `verifyCurrentFileContent`/`verifyFileContent` calls in the test body.
Common situations: Updating refactors/completions/formatting and forgetting to refresh Fourslash baselines; marker or `goTo.*` drift that lands the action in the wrong place; expected text with wrong line endings or trailing whitespace.
Related errors
- verifyCurrentLineContent\n
- Expected at least one js file to be emitted or at least one
- The baseline file ${relativeFileName} has changed. (Run "her
- New baseline created at ${IO.joinPath("tests", "baselines",
- The generated content was "undefined". Return "null" if no b
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/527073fc307484d2.
Report an issue: GitHub.