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

# Stably Test Reporter

> Stream test results and traces to Stably for analytics and AI-powered test maintenance

The Stably Reporter streams your Playwright test results, traces, and screenshots to Stably for debugging and AI-powered maintenance with `stably fix`.

<Info>The Stably Test Reporter is **free to use** — no paid plan required. It also includes built-in [sensitive data scrubbing](#sensitive-data-scrubbing) for traces — a feature not natively available in Playwright.</Info>

With the reporter enabled, you get a rich test results dashboard with detailed run history, failure analysis, and auto-heal reports that show exactly what changed and how Stably fixed your tests.

<Frame>
  <img src="https://mintcdn.com/stablyai/7_G37DLz5v1dtt56/images/stably-reporter-dashboard.png?fit=max&auto=format&n=7_G37DLz5v1dtt56&q=85&s=eb8a1e5ebb80369f9836df7494bc6494" alt="Stably Reporter Dashboard showing test results" width="1905" height="1002" data-path="images/stably-reporter-dashboard.png" />
</Frame>

## Installation

```bash theme={null}
npm install -D @stablyai/playwright-test@latest
```

<Note>Requires Playwright 1.52.0+</Note>

## Configuration

<Tip>
  **Using `stably test`?** The reporter is automatically configured—no setup needed. Skip to [Verify Setup](#verify-setup).
</Tip>

**1. Set environment variables** in your `.env` file:

```bash theme={null}
STABLY_API_KEY=your_api_key_here      # Get from https://app.stably.ai/settings?tab=api-key
STABLY_PROJECT_ID=your_project_id_here # Find in your project URL on app.stably.ai
```

**2. Add the reporter** to `playwright.config.ts`:

```typescript theme={null}
import { defineConfig, stablyReporter } from "@stablyai/playwright-test";
import dotenv from "dotenv";
import path from "path";

dotenv.config({ path: path.resolve(__dirname, ".env") });

export default defineConfig({
  reporter: [
    ["list"],
    stablyReporter({
      apiKey: process.env.STABLY_API_KEY,
      projectId: process.env.STABLY_PROJECT_ID,
    }),
  ],
  use: {
    trace: "on", // Required for debugging in Stably dashboard
  },
});
```

<Tip>
  Set `trace: "on"` instead of the default `"on-first-retry"` to capture traces for all runs.
</Tip>

## Verify Setup

Run a test to confirm the reporter is working:

```bash theme={null}
npx stably test
```

<Frame>
  <img src="https://mintcdn.com/stablyai/p4XCELjP5tjf1Qba/images/stably-test-verify-setup.png?fit=max&auto=format&n=p4XCELjP5tjf1Qba&q=85&s=50177e9d02a28bef4f4d6691c44c7f73" alt="Stably test output showing dashboard URL" width="975" height="219" data-path="images/stably-test-verify-setup.png" />
</Frame>

You should see a dashboard URL printed after tests complete. View results at [app.stably.ai](https://app.stably.ai).

## Using with `stably fix`

The reporter enables AI-powered test maintenance. When tests fail, the reporter automatically prints a `stably fix` command with the run ID:

```bash theme={null}
npx stably test          # Run tests (results stream to Stably)
# On failure, you'll see: 🔧 To auto-heal failed tests, run: stably fix <runId>
stably fix               # AI analyzes failures and generates fixes
```

<Tip>
  `stably fix` auto-detects the run ID so you don't need to copy-paste it. It checks in order: CI environment variables (GitHub Actions, Azure DevOps, Bitbucket, etc.), then the last local run saved by `stably test`. You can always pass an explicit run ID with `stably fix <runId>`. See [Fix Tests (stably fix) — Run ID Detection](/stably-cli/fix#run-id-detection) for details.
</Tip>

## Sensitive Data Scrubbing

Stably can redact sensitive strings (passwords, API keys, tokens) from Playwright traces before they are uploaded. There are two ways to enable scrubbing:

### Automatic scrubbing with `--env`

If you run tests with the `--env` flag, any variable marked **Sensitive** in your [Stably Environment](/stably2/environments) is automatically scrubbed from traces — no config changes needed.

```bash theme={null}
stably --env Staging test
```

Variables marked as Sensitive on the Environments page are identified at runtime and redacted from trace data before upload. See [Environments — Sensitive Variables](/stably2/environments#sensitive-variables) for how to mark variables as sensitive.

### Manual scrubbing with `sensitiveValues`

If you are not using `--env`, or need to scrub additional values beyond what is stored in your environment, pass a `sensitiveValues` string array to the reporter. Each string will be redacted wherever it appears exactly in the trace.

The `sensitiveValues` array accepts any strings — they do not have to come from `process.env`. Use whatever method matches your project's configuration:

```typescript theme={null}
// Option 1: Reference environment variables (if available in process.env)
stablyReporter({
  apiKey: process.env.STABLY_API_KEY,
  projectId: process.env.STABLY_PROJECT_ID,
  sensitiveValues: [
    process.env.TEST_USER_PASSWORD,
    process.env.API_SECRET,
  ],
});

// Option 2: Import from a config file or module
import { secrets } from "./test-config";

stablyReporter({
  apiKey: process.env.STABLY_API_KEY,
  projectId: process.env.STABLY_PROJECT_ID,
  sensitiveValues: [
    secrets.testUserPassword,
    secrets.apiSecret,
  ],
});

// Option 3: Hardcoded strings (not recommended, but supported)
stablyReporter({
  apiKey: process.env.STABLY_API_KEY,
  projectId: process.env.STABLY_PROJECT_ID,
  sensitiveValues: [
    "my-secret-password",
  ],
});
```

<Warning>
  Sensitive values are scrubbed from trace data, but screenshots and videos may still display secrets if they appear on screen during test execution. Avoid entering sensitive data in visible form fields when possible.

  Only exact string matches are scrubbed—partial matches within objects or arrays are not detected.

  To ensure the integrity of Playwright artifacts, the following patterns are never scrubbed—even when included in `sensitiveValues`:

  * The characters `/` and `*` (when alone)
  * Strings containing `/artifact/`, `https://`, `http://`, or `*********`
  * Pure numeric values (e.g., `123`, `456789`)
  * Values of internal keys: `sha1`, `_sha1`, `pageref`, `downloadsPath`, `tracesDir`, `pageId`, and any key ending in `sha1`
</Warning>

## Troubleshooting

| Issue          | Solution                                          |
| -------------- | ------------------------------------------------- |
| Missing traces | Set `trace: "on"` in config, or use `stably test` |
| Auth errors    | Verify `STABLY_API_KEY` and `STABLY_PROJECT_ID`   |

See [full troubleshooting guide](/trouble-shooting/reporter-analytics) for more details.

## Next Steps

<CardGroup cols={2}>
  <Card title="Alerting" icon="bell" href="/run-tests/alerting">
    Configure notifications for test results
  </Card>

  <Card title="Fix Tests (stably fix)" icon="wand-magic-sparkles" href="/stably-cli/fix">
    Automatically diagnose and repair failing tests
  </Card>

  <Card title="SDK Setup Guide" icon="book" href="/getting-started/sdk-setup-guide">
    Complete setup including AI assertions and actions
  </Card>
</CardGroup>
