Skip to content

fix(vitest): read the JSON report from a file so vitest 5 is parsed - #4264

Open
mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/vitest5-json-report
Open

mrhard9090 wants to merge 1 commit into
rtk-ai:developfrom
mrhard9090:fix/vitest5-json-report

Conversation

@mrhard9090

Copy link
Copy Markdown
Contributor

Summary

Fixes #4224

  • On vitest 5, the JSON reporter writes its report to .vitest/json/output.json and prints only JSON report written to <path>. rtk vitest run parsed stdout, so every parser tier failed. It passed that one line through, left the report file in the project, and recorded the run as nearly all saved.
  • rtk now adds --outputFile.json=<temp file> next to --reporter=json and parses the report from that file. The temp file is removed when the run ends. Vitest 4 honours the same option, so both versions take the same path. If the file is missing or empty, rtk parses stdout as before.
  • The report also counts toward the raw output. emit_guarded compares the summary against it, the recovery tee stores it and tracking counts savings from it. Without this, the guard compared a failure summary with the one-line stdout and printed that line instead.
  • If the user passes --outputFile or --outputFile.json, the report path is left alone (detected with arg_tokenizer, before any --).

Test plan

  • New test_vitest_effective_args_send_json_report_to_file, test_vitest_effective_args_keep_explicit_output_file and test_vitest_reads_report_file_instead_of_stdout.
  • End to end on Windows with a project that has one passing and one failing test. On vitest 5.0.2 and 4.1.11, rtk vitest run prints PASS (1) FAIL (1) with the failing test and its assertion error, and exits 1. With both tests passing on 5.0.2 it prints PASS (2) FAIL (0) and exits 0. No .vitest directory and no temp report is left behind.
  • cargo fmt --all && cargo clippy --all-targets (clean) && cargo test on Windows (MSVC): 3744 passed, 2 failed. find_cmd::run_from_args_propagates_find_exit_status and stream::test_read_lines_lossy_preserves_lines_after_invalid_utf8 fail the same way on develop on this machine.

Written with help from Claude Opus 5.5.

Vitest 5 writes the JSON report to .vitest/json/output.json and prints
only its path. Send it to a temp file with --outputFile.json and parse
that, falling back to stdout when no file was written.

Fixes rtk-ai#4224
@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working testing vitest labels Sep 26, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes vitest 5 JSON report parsing by writing the report to a temp file via --outputFile.json instead of relying on stdout, since vitest 5 only prints the file path. The temp file is read back, cleaned up after the run, and used consistently for output filtering, guard comparison, and tracking; explicit user-provided --outputFile/--outputFile.json flags are respected and left untouched.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4224


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working testing vitest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk vitest run loses the whole result on vitest 5: the JSON reporter writes to .vitest/json/output.json, not stdout

2 participants