angular / angular/angular-cli

Allow custom wsEndpoint for Playwright

Open
#33,115 0 comments 0 reactions 0 assignees View on GitHub
area: @angular-devkit/build-angular gemini-triaged
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

### Command

build

### Description

In our project, I've been trying to set up visual regression testing using Vitest, and to make the screenshot tests stable, we want to make those tests in the same environment, regardless of the developers' OS, which can impact the tests. When using Playwright as a browser provider, Vites allows for providing/overriding the WS endpoint, which is not respected & overridden in the unit test builder.

After a quick look at the code, presumably this is being dropped in `browser-provider.ts:164-87` - `providerFactory(..)` function is called with only `baseOptions`, and also, `plugins.ts:265-284` has some more overrides, and comments (`// CLI provider browser options override, if present`)

### Describe the solution you'd like

Ideally, as a developer, I'd like to have better control over the browser provider configuration, instead of having it implicitly overridden on the builder side.

These are the options that I have on my mind, both of them backward compatible with the existing API:

1. Allow full customization for the browser provider

The solution is as simple as not overriding the provider value if defined explicitly in `vitetest-base.config.ts`. This option would be backward compatible with the existing API, but might break the projects that've attempted to override the provider property and haven't noticed that it has no impact.

2. Add `wsEndpoint` property to the builder schema, and allow overriding the value from `angular.json`

Safer solution, but less flexible.

### Describe alternatives you've considered

All other alternatives require significant efforts to support, and require bypassing the Angular builders, or using a different framework for the same purpose.

I'm also happy to make a contribution, but first, I'd like to get an opinion, and maybe get more context on why the browser config is overridden from Angular's side.

Contributor guide

Open the contributing guide

Research direction

Start by reading browser-provider.ts around lines 164-187, especially providerFactory, then inspect the provider overrides in plugins.ts around lines 265-284. Trace how the Playwright configuration reaches the Angular builder and determine which backward-compatible option is appropriate. Done means an explicitly configured wsEndpoint is respected instead of being implicitly overridden.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, playwright, typescript
Domain
build-system, testing-qa, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.