> ## Documentation Index
> Fetch the complete documentation index at: https://jam.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Record end-to-end tests

> Turn end-to-end test runs into Jams. Upload a failed Playwright test from CI, or record a headless browser while the tests run.

A failed end-to-end test in CI usually leaves a stack trace and a guess. A Jam leaves the video, with the run's console logs and network requests on the same timeline. Reviewers watch the failure instead of rerunning it.

Pick one of two approaches:

| Approach | Use it when |
| - | - |
| [Upload a failed Playwright test](#upload-a-failed-playwright-test) | You use Playwright and want a Jam only when a test fails. Nothing changes in your tests. |
| [Record tests live](#record-tests-live) | You want a Jam of every run, recorded live with the browser's console and network. |

> [!NOTE]
>
> CI needs a [personal access token](https://jam.dev/docs/personal-access-tokens.md) in the `JAM_TOKEN` environment variable. The CLI never writes it to disk.

## Upload a failed Playwright test

Playwright saves a video and a trace for failed tests. `jam create jam` reads both. The Jam plays the video with the console and network from the trace, and shows what the test typed with sensitive fields masked.

**1. Keep the video and trace for failed tests**

In `playwright.config.ts`:

```ts theme={"theme":"css-variables"}
use: { video: "retain-on-failure", trace: "retain-on-failure" }
```

**2. Install the CLI in your CI job**

```bash theme={"theme":"css-variables"}
curl -fsSL https://native.jam.dev/install | bash
export PATH="$HOME/.local/bin:$PATH"
```

**3. Upload each failure after the tests**

Run this when the test step fails:

```bash theme={"theme":"css-variables"}
for dir in test-results/*/; do
  jq -n --arg dir "$dir" --arg name "$(basename "$dir")" '{
    kind: "video",
    url: "https://example.com/checkout",
    title: $name,
    videoPath: "\($dir)video.webm",
    playwrightTracePath: "\($dir)trace.zip",
    screenDimensions: { width: 1280, height: 720 }
  }' | jam create jam
done
```

Playwright writes each failed test into its own folder under `test-results/`, so the loop creates one Jam per failure, titled with the folder name. `jq` builds the payload, and `jam create jam` reads it from stdin. Install `jq` first if your runner does not have it.

**4. Post the link**

Each `jam create jam` prints a Jam's `url`. Post the links where your team reviews the run, such as the pull request.

## Record tests live

`jam record run` records a browser while your test command runs. With `--cdp`, the video, console, and network come from the browser itself, so a headless browser on a CI runner records too.

**1. Start Chrome with a debug port**

```bash theme={"theme":"css-variables"}
google-chrome --headless=new --remote-debugging-port=9222 --user-data-dir=/tmp/jam-chrome about:blank &
until curl -s http://127.0.0.1:9222/json/version > /dev/null; do sleep 0.5; done
```

The loop waits until Chrome accepts connections, so the recording does not start too early.

**2. Wrap the tests in jam record run**

```bash theme={"theme":"css-variables"}
jam record run --cdp 9222 --title "Checkout e2e" -- node e2e/checkout.js
```

The wrapped command gets the recorder's address in `JAM_CDP_PROXY`. Connect your test to it, so the recording follows the pages the test opens:

```js theme={"theme":"css-variables"}
const browser = await chromium.connectOverCDP(process.env.JAM_CDP_PROXY);
```

The command keeps the test's exit code, so a failing test still fails the job and still leaves a Jam. Recording a browser page needs `ffmpeg` on the runner.

### With tester-army/e2e

[tester-army/e2e](https://github.com/tester-army/e2e) runs its web engine on Playwright and can attach to a browser you name. The same wrap works, with the endpoint set in the config:

```ts e2e.config.ts theme={"theme":"css-variables"}
engine: web({ connect: { cdpEndpoint: async () => process.env.JAM_CDP_PROXY! } }),
```

```bash theme={"theme":"css-variables"}
jam record run --cdp 9222 --title "Checkout e2e" -- npx e2e run tests/checkout.e2e.ts
```

For one Jam per test attempt instead, so every failed attempt has its own recording, give the engine a `BrowserProvider` whose `acquire` starts `jam record start --cdp` on a fresh Chrome and returns the proxy as the endpoint, and whose `record().stop` runs `jam record stop`. Pass `--marks` to `stop` with one line per test step, and each step lands on the Jam as a comment.

## Next

* For Playwright payload fields, including `--speedup` to cut idle time, see [Create and update Jams](https://jam.dev/docs/cli-reference.md#create-and-update-jams).
* To connect Puppeteer, agent-browser, or an MCP browser tool, see [Get Jams from your agents](https://jam.dev/docs/cli-record-browser.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.