From 2ca5d757b746d661636bc91795fa7d98db10021f Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Wed, 6 Dec 2023 00:10:45 +0200 Subject: [PATCH] Fix expect call in dts test (#15766) --- tests/dts/unit/run.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/dts/unit/run.js b/tests/dts/unit/run.js index 94431b3a6..5e8039335 100644 --- a/tests/dts/unit/run.js +++ b/tests/dts/unit/run.js @@ -29,6 +29,18 @@ describe("Unit tests for dts files", () => { /** @type {import("typescript").Diagnostic[]} */ const diagnostics = ts.getPreEmitDiagnostics(program); - expect(diagnostics).toEqual([]); + expect(diagnostics.map(formatDiagnostic)).toEqual([]); }); }); + +/** + * @param {import("typescript").Diagnostic} diagnostic + */ +function formatDiagnostic({ file, start, code, messageText }) { + let location = ""; + if (file) { + const { line, character } = ts.getLineAndCharacterOfPosition(file, start); + location = `${file.fileName}:${line + 1}:${character + 1} `; + } + return `${location}TS${code}: ${messageText}`; +}