---
title: "Playwright config and run settings | Speedscale Docs"
description: "How a browser journey replay uses the playwright.config at the root of your journeys, which settings the replay overrides, and the run settings that choose browsers and devices, retries and flaky journeys, video, sharding across CI jobs and emulation. Also covers screenshot and ARIA baselines, Accept as baseline, and accessibility scans with axe."
canonical: "https://docs.speedscale.com/guides/browser-journeys/playwright-config/"
---

[Documentation index](https://docs.speedscale.com/guides/llms.txt) | [Markdown](https://docs.speedscale.com/guides/browser-journeys/playwright-config/index.md) | [Canonical page](https://docs.speedscale.com/guides/browser-journeys/playwright-config/)

# Playwright config and run settings

A replay runs your journeys with your own Playwright config, under a few settings it has to control. Run settings, as `proxymock replay` flags or test config fields, change one run without editing the config.

<a id="your-playwright-config"></a>

## Your Playwright config

Put a `playwright.config.ts` at the root of the journeys folder, the folder you pass to `--browser`. Any of `.ts`, `.js`, `.mts`, `.mjs`, `.cts` and `.cjs` works. A config anywhere else, such as one level up next to `package.json`, is not read: move it, or copy the settings you need into one at the journeys root.

The replay keeps the config's projects (browsers, devices and setup projects), `retries`, `workers`, `use` options such as `locale`, `viewport` and `testIdAttribute`, and its `expect` and snapshot settings. A cluster or cloud run carries the config with the journeys.

The replay always sets these, whatever the config says:

| Setting | What the replay does |
| --- | --- |
| `use.baseURL` | Set to `--test-against`, `--target` or `baseUrl` in the test config. Open pages by path. |
| Headless | Every browser runs headless. |
| Proxy | The browser's traffic goes through the replay's proxy, so mocks and recording work. |
| Service workers | Blocked, so no request is answered where the proxy cannot see it. |
| `outputDir`, `reporter` | Replaced, so the replay can read the results and keep the files. |
| `forbidOnly` | On. `test.only` fails the run. |
| `webServer` | Dropped. Start the frontend yourself before the run. |

When the config does not set them, the replay uses `fullyParallel: true`, `retries: 0`, `workers: 1`, `trace: 'retain-on-failure'` and `screenshot: 'only-on-failure'`. Without a config, every journey runs once in Chromium.

Setup projects run first, and their requests go through the proxy like any journey's, so a login in a setup project is answered from the recording when mocks are on. `globalSetup` and `globalTeardown` run in Node outside the proxy, so they reach the real backends. Use a setup project, or a [storage state](https://docs.speedscale.com/guides/browser-journeys/write-journeys/#start-signed-in), when the login should stay off the real APIs.

<a id="an-example-config"></a>

### An example config

journeys/playwright.config.ts

```ts
import os from 'node:os';
import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';

const signedIn = path.join(os.tmpdir(), 'shopper.json');

export default defineConfig({
  retries: 1,
  workers: 2,
  use: {
    locale: 'en-US',
    testIdAttribute: 'data-test',
    video: 'retain-on-failure',
  },
  expect: {
    toHaveScreenshot: { maxDiffPixelRatio: 0.01 },
  },
  projects: [
    { name: 'setup', testMatch: /.*\.setup\.ts/ },
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'], storageState: signedIn },
      dependencies: ['setup'],
    },
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'], storageState: signedIn },
      dependencies: ['setup'],
    },
  ],
});
```

journeys/auth.setup.ts

```ts
import os from 'node:os';
import path from 'node:path';
import { test as setup, expect } from '@playwright/test';

setup('sign in as the test shopper', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill('test-shopper@example.com');
  await page.getByLabel('Password').fill('test-only-password');
  await page.getByRole('button', { name: 'Sign in' }).click();
  await expect(page.getByTestId('account-menu')).toBeVisible();
  await page.context().storageState({ path: path.join(os.tmpdir(), 'shopper.json') });
});
```

The setup project signs in once and saves the session in the temp folder, outside the journeys folder, so it is never packed with the journeys. A session saved under a `.auth` folder, as Playwright's own examples do (`playwright/.auth/user.json`), is also left out when the journeys are packed for a cluster or cloud run. Each journey then runs twice, once in Chromium and once in Firefox, starting signed in. There is no `baseURL` and no `webServer`, because the replay sets the first and drops the second. Use a test account made for the purpose: a journey runs in a cluster and its trace shows what it typed.

<a id="run-settings"></a>

## Run settings

Run settings override the config for one run. They are flags on both `proxymock replay --browser <dir>` and `proxymock cluster replay start --browser <dir>`, and fields of `generator.browser` in the [test config](https://docs.speedscale.com/reference/configuration/browser/).

| Flag | Test config field | What it does |
| --- | --- | --- |
| `--browser-engines chromium,firefox,webkit` | `browsers` | Run every journey in each browser. Branded `chrome` and `msedge` also work where they are installed, so not in a cluster. |
| `--browser-devices "iPhone 15","Pixel 7"` | `devices` | Run every journey on each Playwright device: its viewport, user agent, touch and default browser. |
| `--browser-project <name>` | `projects` | Run only this project of the config, with the projects it depends on. Repeatable. |
| `--browser-retries <n>` | `retries` | Retry a failed journey up to `n` times. |
| `--browser-fail-on-flaky` | `failOnFlaky` | Count a journey that passed only on a retry as failed. |
| `--browser-video <mode>` | `video` | Record video: `off`, `on`, `retain-on-failure` or `on-first-retry`. |
| `--browser-shard <i>/<n>` | `shardIndex`, `shardTotal` | Run share `i` of `n` of the journeys. |
| `--browser-viewport 1280x720` | `emulation.viewportWidth`, `emulation.viewportHeight` | Set the viewport. |
| `--browser-locale de-DE` | `emulation.locale` | Set the browser's locale. |
| `--browser-timezone Europe/Berlin` | `emulation.timezoneId` | Set the browser's time zone. |
| `--browser-color-scheme dark` | `emulation.colorScheme` | `light`, `dark` or `no-preference`. |
| `--browser-permissions geolocation` | `emulation.permissions` | Grant these browser permissions up front. |
| `--browser-geolocation 52.52,13.40` | `emulation.geolocation.latitude`, `emulation.geolocation.longitude` | Set the browser's location. |
| `--browser-workers <n>` | `workers` | Run this many journeys at once. Defaults to the config's `workers`, else `1`. `proxymock replay` only; in a cluster set the field. |
| `--browser-update-snapshots <mode>` | none | `proxymock replay` only. Write the baselines the run produced into the journeys folder: `missing`, `changed` or `all`. See [Screenshots and ARIA snapshots](https://docs.speedscale.com/guides/browser-journeys/playwright-config/#screenshots-and-aria-snapshots). |

The same settings in a test config:

```json
"browser": {
  "enabled": true,
  "browsers": ["chromium", "webkit"],
  "retries": 2,
  "failOnFlaky": true,
  "video": "on-first-retry",
  "emulation": {
    "locale": "de-DE",
    "timezoneId": "Europe/Berlin",
    "colorScheme": "dark"
  }
}
```

<a id="browsers-and-devices"></a>

## Browsers and devices

```bash
proxymock replay --in <recording> --browser ./journeys \
  --test-against http://localhost:3000 --browser-proxy http://localhost:4140 \
  --browser-engines chromium,webkit --browser-devices "iPhone 15"
```

With `--browser-engines` or `--browser-devices` set, the config's projects are replaced by one project per browser and device. With both, every device runs in every browser, named like `iPhone 15 (webkit)`. Projects that other projects depend on, such as a login setup project, still run first. The first project that is not a setup project is the template: its storage state, `testMatch` and other filters carry over to the new projects.

To keep the config's projects and run only some of them, use `--browser-project` instead:

```bash
proxymock replay ... --browser-project firefox
```

On your machine, install the browsers the run needs next to `@playwright/test`, for example `npx playwright install chromium firefox webkit`. In a cluster the generator image is the official Playwright image, which has Chromium, Firefox and WebKit.

Each journey is reported once per project, as `[project] title`, such as `[firefox] shopper checks out`.

<a id="retries-and-flaky-journeys"></a>

## Retries and flaky journeys

With retries, a journey that fails and then passes on a retry is **flaky**. A flaky journey counts as passed, and the terminal summary counts it separately:

```text
  ~ [webkit] shopper checks out (checkout.spec.ts:3) 6.212s flaky: passed on attempt 2

Browser journeys: 4 passed, 0 failed, 0 skipped, 1 flaky
```

Add `--browser-fail-on-flaky`, or set `failOnFlaky`, to count a flaky journey as failed, so it fails the `browserJourneyPassPct` goal. The report shows each journey's attempts and keeps the files of the failed ones; see [Read the results](https://docs.speedscale.com/guides/browser-journeys/read-results/#journeys).

<a id="video"></a>

## Video

`--browser-video` sets Playwright's video mode for the run, over the config's `use.video`:

| Mode | Keeps a video of |
| --- | --- |
| `off` | Nothing. The default. |
| `on` | Every journey. |
| `retain-on-failure` | Each journey that failed. |
| `on-first-retry` | The first retry of each journey that failed once. |

Videos are kept with the report beside the screenshots and traces, and play on the report's **Journeys** tab. When space runs short, the files of failed attempts are kept first.

<a id="split-journeys-across-ci-jobs"></a>

## Split journeys across CI jobs

`--browser-shard <i>/<n>` runs one share of the journeys, the way Playwright's `--shard` does. Each job runs its share as its own replay, with its own result and report. One cluster replay does not fan out across pods by itself: start one replay per share.

Four GitHub Actions jobs, each running a quarter of the journeys in the cluster:

.github/workflows/journeys.yml

```yaml
jobs:
  journeys:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]
    steps:
      - uses: actions/checkout@v4
      - name: Run journeys, share ${{ matrix.shard }} of 4
        run: |
          proxymock cluster replay start --in proxymock/recorded --browser ./journeys \
            --target http://shop-frontend.web:80 \
            --browser-shard ${{ matrix.shard }}/4 --wait
```

Each job exits nonzero when its share misses its goals. The flag works the same way on `proxymock replay --browser` in a job that runs the frontend itself.

<a id="screenshots-and-aria-snapshots"></a>

## Screenshots and ARIA snapshots

`toHaveScreenshot`, `toMatchSnapshot` and `toMatchAriaSnapshot` work as they do in Playwright, against baselines beside the specs:

```ts
test('home page looks right', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveScreenshot('home.png');
  await expect(page.getByRole('navigation')).toMatchAriaSnapshot({ name: 'nav.aria.yml' });
});
```

On your machine, write or refresh the baselines with `--browser-update-snapshots`:

```bash
proxymock replay ... --browser-update-snapshots missing
```

`missing` writes baselines that do not exist yet, `changed` also rewrites the ones that no longer match, and `all` rewrites every one. proxymock prints each file it wrote.

A cluster or cloud run carries the baselines with the journeys: images up to 15 MB in total, and `.yml` ARIA snapshots with the specs.

Playwright names a screenshot baseline after the project and the platform, such as `home-chromium-darwin.png`. A baseline made on a Mac therefore never matches the Linux browsers in a cluster. To get Linux baselines:

1.  Run the journeys in the cluster. The comparison fails because the cluster's baseline is missing, and the report keeps the image the run took.
2.  On the report's **Journeys** tab, expand the journey and select **Accept as baseline** on the image the run took.

The image is stored with the snapshot's journeys, and the next replay of that snapshot compares against it. **Accept as baseline** works on cloud reports of snapshots that carry journeys. Journeys run from a folder on your machine take new baselines with `--browser-update-snapshots` instead.

<a id="accessibility-scans-with-axe"></a>

## Accessibility scans with axe

`@axe-core/playwright` runs an accessibility scan inside a journey:

```ts
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('checkout has no accessibility violations', async ({ page }) => {
  await page.goto('/checkout');
  const results = await new AxeBuilder({ page }).analyze();
  expect(results.violations).toEqual([]);
});
```

On your machine, install it next to the journeys with `npm install -D @axe-core/playwright`. In a cluster the generator image provides it.
