-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: fix ui mode / html reporter and coverage integration #9626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Use config.coverage.htmlDir in UI and browser dev servers - Serve coverage at standardized /coverage/ path (no more basename heuristic) - Remove resolveCoverageFolder helper functions (~70 lines) - Serialize htmlDir to client config - Update client to check htmlDir and use /coverage/index.html - Remove complex path computation and TODO about subdirectory limitation Benefits: - Predictable coverage URL path - Single source of truth for coverage directory - Simplified client and server logic - No configuration limitations Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Remove stale reportsDirectory subdirectory constraint, document the new coverage.htmlDir option, and update Vitest UI section to reflect that coverage UI now works with both html and lcov reporters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ce3b606 to
07ca0c7
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| // notify builtin ui and html reporter after coverage html is generated | ||
| for (const reporter of this.reporters) { | ||
| if (reporter instanceof WebSocketReporter) { | ||
| reporter.onFinishedReportCoverage() | ||
| if ( | ||
| 'onFinishedReportCoverage' in reporter | ||
| && typeof reporter.onFinishedReportCoverage === 'function' | ||
| ) { | ||
| await reporter.onFinishedReportCoverage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reportCoverage happens after onTestRunEnd, so now HTML reporter also needs this to be able to collect coverage html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AriPerkkio that's why I wanted onCoverage as a separate hook, by the way. We have it, but it's coupled to onTestRunEnd
| // infer default based on builtin reporter html output (html and lcov) | ||
| if (!resolved.coverage.htmlDir) { | ||
| const htmlReporter = resolved.coverage.reporter.find(([name]) => name === 'html') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also html-spa if we want to support that 👀
| ## coverage.htmlDir | ||
|
|
||
| - **Type:** `string` | ||
| - **Default:** Automatically inferred from `html` or `lcov` coverage reporters | ||
| - **CLI:** `--coverage.htmlDir=<path>` | ||
|
|
||
| Directory of HTML coverage output to be served in [Vitest UI](/guide/ui) and [HTML reporter](/guide/reporters.html#html-reporter). | ||
|
|
||
| This is automatically configured when using builtin coverage reporters that produce HTML output (`html` and `lcov`). Use this option to override with a custom coverage reporting location when using custom coverage reporters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also mention here that:
Note that setting this option does not change where coverage HTML report is generated. Configure the `reporter` option to change the directory instead.
Description
This PR simplifies how coverage HTML is served in UI mode and HTML reporter by introducing a new
coverage.htmlDiroption.Before: Coverage HTML serving relied on complex path resolution from
coverage.reportsDirectoryand thehtmlreporter'ssubdiroption. This requiredreportsDirectoryto be set as a subdirectory of the HTML report directory and also inconsistency between ui mode and html reporting.After: Coverage HTML is served at a fixed
./coveragesubpath relative to the UI base. The newcoverage.htmlDiroption is automatically inferred fromhtmlorlcovcoverage reporters, and can be explicitly set for custom coverage providers. This removes the directory layout constraint and makes the integration work reliably across UI mode, HTML reporter, browser mode orchestrator html.TODO
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.