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

  1. Apply the diff from the failure message to the expected string.
  2. Re-check that previous marker positioning put the action on the intended location.
  3. Match line endings and trailing newline exactly (`showTextDiff` is whitespace-sensitive).
  4. 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

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


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