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

May 1, 2026 09:18

@gbleu gbleu marked this pull request as draft

May 2, 2026 04:35

@hi-ogawa 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

May 2, 2026

[chatgpt-codex-connector[bot]](/apps/chatgpt-codex-connector)

gbleu pushed a commit to gbleu/vitest that referenced this pull request

May 3, 2026

@claude @gbleu

…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

May 3, 2026

@claude @gbleu

…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

May 3, 2026

@claude @gbleu

…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

May 3, 2026

@claude @gbleu

…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 gbleu marked this pull request as ready for review

May 3, 2026 07:01

[chatgpt-codex-connector[bot]](/apps/chatgpt-codex-connector)

gbleu pushed a commit to gbleu/vitest that referenced this pull request

May 3, 2026

@claude @gbleu

…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.

[chatgpt-codex-connector[bot]](/apps/chatgpt-codex-connector)

gbleu pushed a commit to gbleu/vitest that referenced this pull request

May 3, 2026

@claude @gbleu

…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

@gbleu @claude

…vitest-dev#10242)

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

@gbleu @claude

…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

@gbleu @claude

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

@gbleu @claude

…exception cases

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@gbleu @claude

…-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

May 8, 2026

@claude @gbleu

…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.

@claude @gbleu

…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

@sheremet-va sheremet-va changed the titlefix(junit-reporter): include unhandled errors in JUnit XML report fix(junit): include unhandled errors in JUnit XML report

May 8, 2026

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 }})