Title: test_runner: JUnit report is truncated when a failed test triggers empty context.diagnostic() · Issue #65355 · nodejs/node · GitHub
Open Graph Title: test_runner: JUnit report is truncated when a failed test triggers empty context.diagnostic() · Issue #65355 · nodejs/node
X Title: test_runner: JUnit report is truncated when a failed test triggers empty context.diagnostic() · Issue #65355 · nodejs/node
Description: Version v24.15.0 Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps will reproduce the bug? Create any test file, like junit.test.mjs: import { fail } from 'node:assert/strict'; import { test } from 'node:tes...
Open Graph Description: Version v24.15.0 Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps will reproduce the bug? Create any test file, like junit.test.mjs: import { fail } from 'node:assert...
X Description: Version v24.15.0 Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps will reproduce the bug? Create any test file, like junit.test.mjs: import { fail } from 'node:as...
Opengraph URL: https://github.com/nodejs/node/issues/65355
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_runner: JUnit report is truncated when a failed test triggers empty context.diagnostic()","articleBody":"### Version\n\nv24.15.0\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.26200.0 x64\n```\n\n### Subsystem\n\ntest_runner\n\n### What steps will reproduce the bug?\n\n1. Create any test file, like `junit.test.mjs`:\n\n ```js\n import { fail } from 'node:assert/strict';\n import { test } from 'node:test';\n\n await test('testName', (context) => {\n context.diagnostic('');\n fail();\n });\n ```\n2. Run the test via console\n\n ```powershell\n node --test --test-reporter=junit \".\\junit.test.mjs\"\n ```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nThe JUnit reporter should gracefully handle empty diagnostic messages (e.g., `context.diagnostic('')`). It should format them as empty XML comments (`\u003c!-- -->`) without throwing errors, aligning with the default `spec` reporter which successfully prints empty lines for empty diagnostic events. The generated XML report must remain valid and fully closed with the `\u003c/testsuites>` tag.\n\n\n### What do you see instead?\n\nWhen a failed test contains an empty diagnostic call, the internal XML formatter (`treeToXML`) evaluates the falsy empty string `if (comment)` as false and mistakenly tries to read `ObjectEntries(attrs)` from an undefined object. This causes an unhandled `TypeError` inside the stream generator, silently destroying the stream and leaving the JUnit XML report truncated and broken.\n\nStack trace:\n\n```text\nTypeError: Cannot convert undefined or null to object\n at entries (\u003canonymous>)\n at treeToXML (node:internal/test_runner/reporter/junit:46:7)\n at junitReporter (node:internal/test_runner/reporter/junit:160:11)\n```\n\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/AlexCannonball","@type":"Person","name":"AlexCannonball"},"datePublished":"2026-08-17T18:25:41Z","url":"https://github.com/nodejs/node/issues/65355"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c56c5141-a7e3-bd5e-e5da-ec204ed1d3b1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5F0:36D84F:817BFC:ACA2B4:6AED299E |
| html-safe-nonce | 1f9533f758200cb156ade63b232659233f3c9859cf98b1447928eba0b929d904 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUYwOjM2RDg0Rjo4MTdCRkM6QUNBMkI0OjZBRUQyOTlFIiwidmlzaXRvcl9pZCI6IjU5NDYyOTA1MjEyNTkxOTA2ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d7d14b8d1b4c401b6475f3854c0229de8c4a2f12cfe6190ac3bdf7b50ee48108 |
| hovercard-subject-tag | issue:5174184609 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/65355/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0b6f74cf17001ebfbc07ceba40394b937aedc1b648884e01801ca7b981697263/nodejs/node/issues/65355 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0b6f74cf17001ebfbc07ceba40394b937aedc1b648884e01801ca7b981697263/nodejs/node/issues/65355 |
| og:image:alt | Version v24.15.0 Platform Microsoft Windows NT 10.0.26200.0 x64 Subsystem test_runner What steps will reproduce the bug? Create any test file, like junit.test.mjs: import { fail } from 'node:assert... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexCannonball |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width