Search code examples
playwrightgoogle-chrome-flagscomponent-testing

How to specify browser flags for Playwright component tests?


In a Playwright component test, is there a way to pass flags to the browser instance that gets run? For example, for Chrome: --use-fake-ui-for-media-stream, --use-file-for-fake-audio-capture, and similar.


Solution

  • Add launchoptions to the project in playwright.config:

    export default defineConfig({
      // ..
      projects: [
        {
          name: "Chrome",
          use: {
            browserName: "chromium",
            launchOptions: {
              args: [
                "--use-fake-ui-for-media-stream",
                "--use-file-for-fake-audio-capture",
              ],
            },
          },
        },
      ],
    });