diff --git a/tools/github_reporter/index.js b/tools/github_reporter/index.js index 194ca08fe68954..9dc6f91a3faafc 100644 --- a/tools/github_reporter/index.js +++ b/tools/github_reporter/index.js @@ -19156,6 +19156,18 @@ var DIAGNOSTIC_KEYS = { var DIAGNOSTIC_VALUES = { duration_ms: (value) => `${Number(value).toFixed(3)}ms` }; +function extractLocation(data) { + let { line, column, file } = data; + const error = data.details?.error; + file = getFilePath(file); + if (error) { + const errorLocation = parseStack(error, file); + file = getFilePath(errorLocation?.file ?? file) ?? file; + line = errorLocation?.line ?? line; + column = errorLocation?.column ?? column; + } + return { file, startLine: line, startColumn: column }; +} module.exports = async function githubReporter(source) { if (!process.env.GITHUB_ACTIONS) { for await (const _ of source) @@ -19178,23 +19190,18 @@ module.exports = async function githubReporter(source) { if (error?.code === "ERR_TEST_FAILURE" && error?.failureType === "subtestsFailed") { break; } - let filePath = getFilePath(event.data.file); - const location = parseStack(error, filePath); - filePath = getFilePath(location?.file ?? filePath) ?? filePath; core.error(util.inspect(error, { colors: false, breakLength: Infinity }), { - file: filePath, - startLine: location?.line, - startColumn: location?.column, + ...extractLocation(event.data), title: event.data.name }); counter.fail += 1; break; } case "test:diagnostic": - if (event.data.nesting === 0) { + if (event.data.file === void 0 || event.data.line === void 0 || event.data.column === void 0) { diagnostics.push(event.data.message); } else { - core.notice(event.data.message, { file: getFilePath(event.data.file) }); + core.notice(event.data.message, extractLocation(event.data)); } break; default: diff --git a/tools/github_reporter/package.json b/tools/github_reporter/package.json index 265b76d9ff347a..638a489d135084 100644 --- a/tools/github_reporter/package.json +++ b/tools/github_reporter/package.json @@ -1,6 +1,6 @@ { "name": "@reporters/github", - "version": "1.5.4", + "version": "1.6.0", "description": "A github actions reporter for `node:test`", "type": "commonjs", "keywords": [