{"record":{"id":"bb37583c6dd86bb3","repo":"microsoft/TypeScript","slug":"verifycurrentlinecontent-n","errorCode":null,"errorMessage":"verifyCurrentLineContent\\n","messagePattern":"verifyCurrentLineContent\\\\n","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/fourslashImpl.ts","lineNumber":3038,"sourceCode":"        const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle, baseIndentSize);\r\n        const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);\r\n        if (actual !== numberOfSpaces) {\r\n            this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);\r\n        }\r\n    }\r\n\r\n    public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0): void {\r\n        const actual = this.getIndentation(fileName, position, indentStyle, baseIndentSize);\r\n        const lineCol = this.getLineColStringAtPosition(position);\r\n        if (actual !== numberOfSpaces) {\r\n            this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);\r\n        }\r\n    }\r\n\r\n    public verifyCurrentLineContent(text: string): void {\r\n        const actual = this.getCurrentLineContent();\r\n        if (actual !== text) {\r\n            throw new Error(\"verifyCurrentLineContent\\n\" + displayExpectedAndActualString(text, actual, /*quoted*/ true));\r\n        }\r\n    }\r\n\r\n    public verifyCurrentFileContent(text: string): void {\r\n        this.verifyFileContent(this.activeFile.fileName, text);\r\n    }\r\n\r\n    private verifyFileContent(fileName: string, text: string) {\r\n        const actual = this.getFileContent(fileName);\r\n        if (actual !== text) {\r\n            throw new Error(`verifyFileContent in file '${fileName}' failed:\\n${showTextDiff(text, actual)}`);\r\n        }\r\n    }\r\n\r\n    public verifyFormatDocumentChangesNothing(): void {\r\n        const { fileName } = this.activeFile;\r\n        const before = this.getFileContent(fileName);\r\n        this.formatDocument();\r","sourceCodeStart":3020,"sourceCodeEnd":3056,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/fourslashImpl.ts#L3020-L3056","documentation":"Assertion failure in the four-phase test harness (`src/harness/fourslashImpl.ts`). `verifyCurrentLineContent(text)` recomputes the line under the caret and compares it to `text`; on mismatch it throws `Error(\"verifyCurrentLineContent\\n\" + expected-vs-actual). This is a test-authoring assertion, not production code.","triggerScenarios":"Writing a Fourslash test where the marker positions or expected text don't match what the language service produced after an edit/completion. The harness finds the current line from the caret marker, so wrong marker placement also triggers it.","commonSituations":"Updating Fourslash baselines after a formatting/indentation behavior change; off-by-one marker placement; expected string that doesn't include leading indentation; behavior change in completion/format that wasn't reflected in the test.","solutions":["Copy the actual line from the failure diff into the expected `text`.","Re-check marker positions — the harness uses the caret to find the line.","Account for indentation: the expected string must include leading whitespace.","If the new behavior is correct, update the test; if not, fix the feature."],"exampleFix":"// before\nfourshaft.verifyCurrentLineContent(\"const x = 1;\"); // actual has different indent/text\n// after\nfourshaft.verifyCurrentLineContent(\"    const x = 1;\");  // copied from actual","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["When a Fourslash assertion fails, paste the harness's reported `actual` rather than guessing.","Keep expected strings aligned with the indentation style the formatter emits.","Re-run only the affected Fourslash test for fast feedback."],"tags":["test-harness","fourslash","assertion","formatting"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}