Conversation
This adds a new `browser_launch_opts` configuration option that allows
passing additional arguments to Playwright's browserType.launch().
This is useful for scenarios like:
- Enabling fake media streams for testing audio/video capture
- Passing custom browser flags for specific test requirements
Example usage:
```elixir
config :phoenix_test,
playwright: [
browser_launch_opts: [
args: [
"--use-fake-ui-for-media-stream",
"--use-fake-device-for-media-stream"
]
]
]
```
2d289cd to
12bb360
Compare
ftes
left a comment
There was a problem hiding this comment.
Nice, I like it.
Thanks Andrew, also for taking the time to describe your use case.
I find that very valuable as reference.
Just some minor comments before we get this in.
Test getUserMedia with and without fake media device flags to verify the browser launch options actually affect browser behavior.
|
thanks for the fast response @ftes, I just commited a better test and I'll make the changes you requested here. |
|
ok @ftes, feel free to review now. |
|
also, do you want me to create a PR to |
ftes
left a comment
There was a problem hiding this comment.
Beautiful, I like the integration test.
Couple more suggestions/questions.
|
ok ready again @ftes |
| end | ||
| end | ||
|
|
||
| defmodule PhoenixTest.Playwright.BrowserLaunchOptsWithoutFlagsTest do |
|
Beautiful, let's get this merged.
Sure, would be great to document |
|
Looks like we have to skip these for websocket connection. |
This adds a new
browser_launch_optsconfiguration option that allows passing additional arguments to Playwright's browserType.launch().Example usage:
There are existing options for messing with the Page Context and Browser Context, I'm not a playwright expert so I'm not even 100% on how these things differ, and the playwright API is quite complex, but basically although there's a lot of overlap here, you can't use those configs to edit what is actually sent to playwright when you start the browser process--which is what you need to do if you want to pass cli level flags to the browser.
The background on this is at Jump, where we use your library quite a bit, we have a react powered audio recorder interface that does not load properly in our playwright tests. I realized we could actually get it to initialize properly if we pass the
--use-fake-ui-for-media-streamand-use-fake-device-for-media-streamflags to the browser when playwright initializes it.Obviously every playwright API is a little different, and in this library we have this pattern of configuring a lot of stuff in the global config + the overrides in exunit tags, so that seemed like a good way to go about it.
This kinda page is the closest to some kind of official documentation on this on the playwright docs site, but its also not very well documented even in playwright itself that you can do this. In fact they kind of discourage you from doing it almost, but it does in fact work: https://playwright.dev/docs/api/class-browsertype#browser-type-launch