visual-report-status-from-vitest - #9115
Conversation
|
@Vaivaswat2244 kindly review |
Vaivaswat2244
left a comment
There was a problem hiding this comment.
Hi @yashgoyal0110 ! Thanks a lot for your pr. It looks great. I've left a few comments. Have a look and let me know if you have any questions or need clarification.
| reportedStatus === NOT_RUN || | ||
| reportedStatus === PASSED | ||
| ) { | ||
| status = reportedStatus; |
There was a problem hiding this comment.
When vitest says passed, the disk is never consulted, so a stale -diff.png renders a Diff panel next to a PASS badge, and a missing actual renders the missing-image notice under one. Both reproducible locally.
Could skip rendering the diff and the missing-image notice when the status is PASSED, since neither is meaningful then. If you'd rather not hide a real disagreement, a third state that says so is fine too, but showing both without comment is the one option I'd avoid.
| // Percentages only make sense against the tests that actually ran. | ||
| const executedTests = tests.passed + tests.failed; | ||
| const executedScreenshots = | ||
| screenshots.passed + screenshots.failed + screenshots.notCaptured; |
There was a problem hiding this comment.
notCaptured shouldn't be in this denominator, it's labelled "% of screenshots compared" below and those are the ones that were never compared.
Dropping it from executedScreenshots is enough, it's already reported on its own line.
| No vitest results were found at <code>${escapeHTML(path.relative(process.cwd(), resultsFile))}</code>, | ||
| so statuses below were inferred from the screenshots on disk. Tests that | ||
| were skipped or never ran are indistinguishable from failures in this mode. | ||
| Run the tests with <code>--reporter=json --outputFile.json=test/unit/visual/test-results.json</code> |
There was a problem hiding this comment.
If the reporter moves into config, this should just say to re-run npm test, since there'd be no flags for a contributor to pass.
| id: test | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: npm test -- --project=unit-tests | ||
| run: npm test -- --project=unit-tests --reporter=default --reporter=json --outputFile.json=./test/unit/visual/test-results.json |
There was a problem hiding this comment.
I think this should go in the Vitest config, since a regular contributor won't add this many flags just to generate a report, especially given that most of our contributors are students.
That's on me, the command in the issue was a CLI example and it reads like it belongs in the workflow. Config is the better home for it.
Can you check once again if that works?
fixes: #9113
Problem
visual-report.jsinferred status from disk (hasExpected && hasActual && !hasDiff), so a test with no actual screenshot was indistinguishable from one that failed.Confirmed against the tree: 322
metadata.jsondirectories, 71 underWebGPU/(CI runs--project=unit-tests, which excludescases/webgpu.js), plus one{ skip: true }incases/noise.js:34. 71 + 1 + 1 real failure = the 73 reported.Fix
The report now reads vitest's json reporter output as the source of truth, matching each result to its screenshot directory via
ancestorTitlesand the same/→%2FescapingvisualTest.jsuses. Four states: passed, failed,skipped, not run. Percentages are taken against tests run. Falls back to the old disk heuristic with a visible banner when the JSON is absent, so
node visual-report.jsstill works locally.Testing
Ran the full suite locally, then generated the report with both the old and new
generator against the same
test-results.jsonand screenshots on disk:npm test -- --project=unit-tests --reporter=default --reporter=json
--outputFile.json=./test/unit/visual/test-results.json
node visual-report.js
The 71 "not run" are the
WebGPU/tests, excluded because CI runs--project=unit-tests. The 1 skip is{ skip: true }incases/noise.js:34.The 1 failure is a pre-existing local rendering diff in
Typography > textWeight > can control non-variable fonts, unrelated to this change.Also exercised the fallback paths: missing JSON (disk heuristic + warning banner),
malformed JSON (same), and empty
testResults(all tests reported as not run).