fix(junit): include unhandled errors in JUnit XML report by gbleu · Pull Request #10244 · vitest-dev/vitest (original) (raw)
AI review requested due to automatic review settings
gbleu marked this pull request as draft
hi-ogawa removed the maybe automated
User is likely an AI agent, or the content was generated by an AI assistant without user control
label
[](/apps/chatgpt-codex-connector)
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
https://claude.ai/code/session_01JXdkg96wE9TfHVqABDdd8G
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
https://claude.ai/code/session_01JXdkg96wE9TfHVqABDdd8G
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
gbleu marked this pull request as ready for review
[](/apps/chatgpt-codex-connector)
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
[](/apps/chatgpt-codex-connector)
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
The JUnit reporter previously ignored process-level unhandled rejections /
uncaught exceptions, leaving <testsuites> and <testsuite> with
failures="0" errors="0" even though Vitest counted them in its summary
and exited with code 1. CI systems gating on the JUnit artifact (Jenkins,
GitLab MR widget, Azure Pipelines, CircleCI) thus reported the build green
when it had actually failed.
Surface the captured unhandledErrors (already passed to onTestRunEnd
on the Reporter interface) as a synthetic <testsuite name="vitest unhandled errors"> containing one <testcase> per error with an <error> element.
Top-level <testsuites> now reports errors=N and includes them in tests=.
The synthetic testcase preserves error.type ("Uncaught Exception" /
"Unhandled Rejection") in the title and surfaces VITEST_TEST_PATH via
file= when addFileAttribute: true, so CircleCI / GitLab can map the
error back to its source file.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
…k rendering
In multi-project workspaces, capturePrintError previously fell back to the default project when rendering unhandled errors, which could resolve paths in the "originated in " line against the wrong project root. Look up the owning TestModule via VITEST_TEST_PATH and pass its project/task into writeErrorElement, mirroring how the existing path resolves project context per-task.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Rolldown's source map anchors the inline async IIFE on error.test.ts:16 one column later than rollup, breaking the "format error" snapshot on the Rolldown CI job. Mirror the pattern in test/e2e/test/public-api.test.ts and use rolldownVersion to normalize the drifted column back to rollup's canonical position so the snapshot remains bundler-agnostic.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
…exception cases
- Multi-project fixture: two projects each producing an unhandled rejection. Verifies the VITEST_TEST_PATH → testModules.find lookup attributes each error to its owning project (file= matches origin, stack resolves relative to the right project root).
- Multi-error fixture: one file producing two rejections plus a setTimeout uncaught exception. Exercises the writeUnhandledErrorsTestsuite loop, the tests=/errors= arithmetic, and confirms the title prefix comes from error.type ("Unhandled Rejection:" vs "Uncaught Exception:").
- Replaces the standalone "addFileAttribute attaches source path" toMatch-regex test; its assertion is now folded into the multi-project snapshot which uses addFileAttribute: true.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
…-project determinism
Projects in a multi-project run finish in non-deterministic order, and the JUnit reporter emits blocks in completion order — so the multi-project snapshot was racy on CI. Sort the blocks by name in the test-side stabilizer.
No existing util fits: the rest of the file uses an ad-hoc stabilizeReport and there's no shared JUnit-XML test helper in the repo. The sort is scoped to this test file. Existing snapshots already happen to be in alphabetical order, so they don't change.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
gbleu pushed a commit to gbleu/vitest that referenced this pull request
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
…istic order
Sort unhandled errors by (VITEST_TEST_PATH, type, name, message) before emitting the synthetic so the testcase order is stable across runs even when multiple workers/projects report errors concurrently. Sort cross-file blocks by resolved suiteName for the same reason. Both use plain byte compare (not localeCompare) so output is identical across machines and ICU versions.
Removes the test-side sortTestsuites stabilizer, which was masking the non-determinism that is now fixed at the source.
Addresses review comment on vitest-dev#10244.
sheremet-va changed the title
fix(junit-reporter): include unhandled errors in JUnit XML report fix(junit): include unhandled errors in JUnit XML report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})