diff --git a/content/api/plugins/browser-launch-api.md b/content/api/plugins/browser-launch-api.md index b4db037704..2e60d61c1f 100644 --- a/content/api/plugins/browser-launch-api.md +++ b/content/api/plugins/browser-launch-api.md @@ -48,10 +48,11 @@ following properties: | `preferences` | `object` | An object describing browser preferences. Differs between browsers. See [Changing browser preferences](#Changing-browser-preferences) for details. | | `args` | `string[]` | An array of strings that will be passed as command-line args when the browser is launched. Has no effect on Electron. See [Modify browser launch arguments](#Modify-browser-launch-arguments) for details. | | `extensions` | `string[]` | An array of paths to folders containing unpacked WebExtensions to be loaded before the browser starts. Note: Electron currently only supports Chrome DevTools extensions. See [Add browser extensions](#Add-browser-extensions) for details. | +| `env` | `object` | An object of environment variables to pass to the launched browser. See [Configure browser environment](#Configure-browser-environment) for details. | ## Usage -### Modify browser launch arguments, preferences, and extensions +### Modify browser launch arguments, preferences, extensions, and environment Using the [setupNodeEvents](/guides/tooling/plugins-guide#Using-a-plugin) function you can tap into the `before:browser:launch` event and modify how @@ -120,6 +121,24 @@ on('before:browser:launch', (browser, launchOptions) => { ::: +#### Configure browser environment: + + +This option is not supported when targeting Electron. + + +:::cypress-plugin-example + +```js +on('before:browser:launch', (browser, launchOptions) => { + launchOptions.env.CUSTOM_ENV_VALUE = '1' + + return launchOptions +}) +``` + +::: + #### Changing browser preferences: Here are preferences available for the currently supported browsers: