diff --git a/tests/dts/unit/run.js b/tests/dts/unit/run.js index 94431b3a6b9b..5e803933525b 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}`; +}