Skip to content

fix(browser): fix headless config and enable coverage support#922

Merged
fi3ework merged 4 commits intomainfrom
max/2026-01-29--20-27
Jan 29, 2026
Merged

fix(browser): fix headless config and enable coverage support#922
fi3ework merged 4 commits intomainfrom
max/2026-01-29--20-27

Conversation

@fi3ework
Copy link
Copy Markdown
Member

@fi3ework fi3ework commented Jan 29, 2026

Summary

fix #917.

  • Prioritize project-level browser configuration (headless, browser name, port) over root config in hostController
  • Register coverage plugin in browser-mode Rsbuild instance to solve SWC transform registration errors
  • Synchronize Rsbuild environment name with browser project name to ensure coverage transform mapping
  • Collect and forward globalThis.__coverage__ data from the browser client to the host
  • Merge browser coverage results into the global coverage report for both mixed and browser-only runs
  • Add unit tests for browser config resolution logic
  • Add E2E tests covering browser-mode coverage for both tested and untested files

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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

  • Browser Configuration Prioritization: Project-level browser configurations (headless, browser name, port) now take precedence over root configurations within the hostController.
  • Browser Coverage Plugin Registration: The coverage plugin is now registered in the browser-mode Rsbuild instance, resolving SWC transform registration issues.
  • Rsbuild Environment Name Synchronization: Rsbuild environment names are synchronized with browser project names to ensure correct coverage transform mapping.
  • Client-Side Coverage Data Collection: globalThis.__coverage__ data is collected from the browser client and forwarded to the host.
  • Unified Coverage Reporting: Browser coverage results are merged into the global coverage report, supporting both mixed (browser and node) and browser-only test runs.
  • New Unit Tests for Config Resolution: Added unit tests to verify the browser configuration resolution logic.
  • New E2E Tests for Browser Coverage: Added end-to-end tests to cover browser-mode coverage collection for both tested and untested files.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fi3ework fi3ework force-pushed the max/2026-01-29--20-27 branch from 9b8a45c to 7b0eedd Compare January 29, 2026 12:45
@fi3ework fi3ework marked this pull request as ready for review January 29, 2026 15:03
Copilot AI review requested due to automatic review settings January 29, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

fi3ework and others added 3 commits January 29, 2026 23:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@fi3ework fi3ework force-pushed the max/2026-01-29--20-27 branch from fa3cc0c to bc01cfc Compare January 29, 2026 16:15
@fi3ework fi3ework enabled auto-merge (squash) January 29, 2026 16:16
@fi3ework fi3ework merged commit 01a0f3a into main Jan 29, 2026
15 of 17 checks passed
@fi3ework fi3ework deleted the max/2026-01-29--20-27 branch January 29, 2026 16:45
@fi3ework fi3ework mentioned this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Broken coverage in Browser mode

2 participants