Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update browser launch options for env key #4723

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion content/api/plugins/browser-launch-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -120,6 +121,24 @@ on('before:browser:launch', (browser, launchOptions) => {

:::

#### Configure browser environment:

<Alert type="warning">
This option is not supported when targeting Electron.
</Alert>

:::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:
Expand Down