fix(browser): fix headless config and enable coverage support#922
fix(browser): fix headless config and enable coverage support#922
Conversation
Summary of ChangesHello @fi3ework, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the browser testing capabilities by addressing configuration precedence and introducing robust code coverage support. It ensures that browser-specific settings are correctly applied and that comprehensive coverage data from browser tests is seamlessly integrated into the overall reporting, improving the reliability and observability of browser-based test suites. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively adds coverage support for browser tests and fixes browser configuration resolution. The changes are well-structured, and the inclusion of both E2E and unit tests is great. I've found one potential issue related to how results are merged in watch mode when both browser and node tests are present.
9b8a45c to
7b0eedd
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes browser mode coverage collection (issue #917) by implementing proper coverage plugin registration, configuration prioritization, and data collection flow for browser tests.
Changes:
- Enables coverage plugin registration in browser-mode Rsbuild instances with proper configuration mapping
- Prioritizes project-level browser configuration over root configuration for headless mode, browser selection, and port settings
- Implements coverage data collection from browser tests and merges results with node tests for unified reporting
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/core/runTests.ts | Adds coverage generation for browser-only test runs and merges browser results with node results for mixed test environments |
| packages/core/src/browser.ts | Exports loadCoverageProvider function to enable browser package to load coverage providers |
| packages/browser/tests/hostController.test.ts | Adds unit tests to verify project-level browser config properly overrides root config |
| packages/browser/src/hostController.ts | Implements project-level config prioritization, registers coverage plugin, and synchronizes environment name with project name |
| packages/browser/src/client/entry.ts | Collects coverage data from globalThis.__coverage__ and attaches it to test file results |
| e2e/browser-mode/fixtures/ports.ts | Adds port configuration for browser-coverage E2E test fixture |
| e2e/browser-mode/fixtures/browser-coverage/tests/sum.test.ts | Adds E2E test for a file with coverage |
| e2e/browser-mode/fixtures/browser-coverage/src/sum.ts | Adds tested source file for coverage E2E validation |
| e2e/browser-mode/fixtures/browser-coverage/src/multiply.ts | Adds untested source file for coverage E2E validation |
| e2e/browser-mode/fixtures/browser-coverage/rstest.config.ts | Configures browser mode with coverage enabled for E2E testing |
| e2e/browser-mode/coverage.test.ts | Validates browser coverage collection for both tested and untested files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
fa3cc0c to
bc01cfc
Compare
Summary
fix #917.
hostControllerglobalThis.__coverage__data from the browser client to the hostRelated Links
Checklist