Skip to content

Commit 2ca5d75

Browse files
authored
Fix expect call in dts test (#15766)
1 parent 15c7428 commit 2ca5d75

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/dts/unit/run.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ describe("Unit tests for dts files", () => {
2929
/** @type {import("typescript").Diagnostic[]} */
3030
const diagnostics = ts.getPreEmitDiagnostics(program);
3131

32-
expect(diagnostics).toEqual([]);
32+
expect(diagnostics.map(formatDiagnostic)).toEqual([]);
3333
});
3434
});
35+
36+
/**
37+
* @param {import("typescript").Diagnostic} diagnostic
38+
*/
39+
function formatDiagnostic({ file, start, code, messageText }) {
40+
let location = "";
41+
if (file) {
42+
const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
43+
location = `${file.fileName}:${line + 1}:${character + 1} `;
44+
}
45+
return `${location}TS${code}: ${messageText}`;
46+
}

0 commit comments

Comments
 (0)