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

# Node.js CLI for Playwright

> Install @testdino/playwright and stream Playwright test results to TestDino live, with config setup, CLI flags, and CI usage.

`@testdino/playwright` streams Playwright test results to TestDino as a run executes. Results appear on the dashboard during the run, with no separate upload step. Paste the AI prompt below, or follow Installation and Set up.

## Prerequisites

* Node.js `>= 18.0.0`
* `@playwright/test` `>= 1.52.0`
* TestDino API token ([generate one](/guides/generate-api-keys))
* Git initialized repository (for commit and branch metadata)

## Set up with an AI agent

<Prompt description="Use this pre-built prompt to integrate @testdino/playwright into your project." actions={["copy", "cursor"]}>
  Integrate TestDino into this Playwright (Node.js) project so test results stream live via @testdino/playwright.

  **Install**

  ```bash theme={null}
  npm install @testdino/playwright
  ```

  **Add TestDino to playwright.config.ts|js|mjs, keeping any existing reporter entries:**

  ```typescript theme={null}
  import { defineConfig } from '@playwright/test';

  export default defineConfig({
    reporter: [
      ['@testdino/playwright', {
        token: process.env.TESTDINO_TOKEN,
        serverUrl: "https://reporter.testdino.com",
      }],
    ],
  });
  ```

  **Run the tests:**

  ```bash theme={null}
  export TESTDINO_TOKEN=your-api-key
  npx playwright test
  ```

  **Rules**

  * Read the token from process.env.TESTDINO\_TOKEN. Never hardcode or commit a real token.
  * Do not add a post-run upload step. Results stream during the run.

  Docs: [https://docs.testdino.com/cli/testdino-playwright-nodejs](https://docs.testdino.com/cli/testdino-playwright-nodejs)
</Prompt>

## Quick Reference

| Topic                       | Link                            | Best for          |
| :-------------------------- | :------------------------------ | :---------------- |
| Install the package         | [Installation](#installation)   | First-time setup  |
| Add TestDino to your config | [Set up](#set-up)               | Streaming results |
| CLI flags                   | [CLI flags](#cli-flags)         | Passing options   |
| Group sharded runs          | [Sharded runs](#sharded-runs)   | CI with shards    |
| Code coverage               | [Code coverage](#code-coverage) | Istanbul coverage |

## Installation

```bash theme={null}
npm install @testdino/playwright
```

View the package on npm: [@testdino/playwright ↗](https://www.npmjs.com/package/@testdino/playwright).

## Set up

Add TestDino to the `reporter` array in your Playwright config. This is the only entry TestDino needs. Other reporters (`html`, `list`) are optional and yours to keep.

```typescript playwright.config.ts theme={null}
import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['@testdino/playwright', {
      token: process.env.TESTDINO_TOKEN,
      serverUrl: "https://reporter.testdino.com",
    }],
  ],
});
```

Set your token and run tests the way you already do. Results stream to TestDino as the run executes.

```bash theme={null}
export TESTDINO_TOKEN="$TESTDINO_TOKEN"
npx playwright test
```

<Accordion title="Prefer not to edit your config?">
  Run `tdpw test` instead of `npx playwright test`. Same result, no config change.

  ```bash theme={null}
  npx tdpw test -t "$TESTDINO_TOKEN" --server-url https://reporter.testdino.com
  ```

  It wraps `npx playwright test`, so any Playwright flag passes through, for example `npx tdpw test --project=chromium --shard=1/3`.
</Accordion>

## CLI flags

Set the token with `-t` or the `TESTDINO_TOKEN` environment variable. All other flags are optional.

```bash theme={null}
npx tdpw test -t "$TESTDINO_TOKEN" --server-url https://reporter.testdino.com --tags "regression,smoke"
```

| Flag                  | Environment variable  | Description                                              |
| :-------------------- | :-------------------- | :------------------------------------------------------- |
| `-t, --token <token>` | `TESTDINO_TOKEN`      | API token. Required.                                     |
| `--server-url <url>`  | `TESTDINO_SERVER_URL` | Streaming endpoint. Use `https://reporter.testdino.com`. |
| `--ci-run-id <id>`    | -                     | Group sharded runs into a single run                     |
| `--tags <csv>`        | `TESTDINO_TAGS`       | Run labels, comma-separated                              |
| `--coverage`          | -                     | Collect Istanbul code coverage                           |
| `--no-artifacts`      | -                     | Skip screenshot, video, and trace uploads                |
| `--debug`             | `TESTDINO_DEBUG`      | Print debug logs                                         |

## Sharded runs

Pass the same `--ci-run-id` to every shard. TestDino groups them into a single logical run on the dashboard.

```bash theme={null}
npx tdpw test --ci-run-id "$CI_RUN_ID" -- --shard=1/4
```

In the config path, set the `ciRunId` option and pass `--shard` to `npx playwright test` as usual.

## Code coverage

Instrument your app with Istanbul so it exposes `window.__coverage__`, import the TestDino fixture in your tests, then enable coverage:

```bash theme={null}
npx tdpw test --coverage
```

Coverage merges across shards automatically. Learn more in [Code Coverage](/guides/playwright-code-coverage).

## Environment variables

| Variable              | Description                                          |
| :-------------------- | :--------------------------------------------------- |
| `TESTDINO_TOKEN`      | Authentication token                                 |
| `TESTDINO_SERVER_URL` | Streaming endpoint (`https://reporter.testdino.com`) |
| `TESTDINO_TAGS`       | Default comma-separated run tags                     |
| `TESTDINO_DEBUG`      | Enable debug logging                                 |

## What gets collected

| Category    | Data                                                                                      |
| :---------- | :---------------------------------------------------------------------------------------- |
| Git         | Branch, commit hash, author, message, repository URL                                      |
| CI          | Provider, build ID, PR details                                                            |
| System      | OS, CPU, memory, Node.js version                                                          |
| Playwright  | Version, workers, projects, shard info                                                    |
| Artifacts   | Screenshots, videos, traces (unless `--no-artifacts`)                                     |
| Annotations | `testdino:` annotations from test metadata ([guide](/guides/playwright-test-annotations)) |

## Use in CI/CD

Set `TESTDINO_TOKEN` as a CI secret, keep TestDino in your `playwright.config`, and run `npx playwright test`. Each guide below has a full pipeline config with sharding and troubleshooting.

<div className="integration-cards">
  <CardGroup cols={3}>
    <Card title="GitHub Actions" img="https://mintcdn.com/testdino/Ua7R4RmzUY5yacWr/images/github-svgrepo-com.svg?fit=max&auto=format&n=Ua7R4RmzUY5yacWr&q=85&s=0055a83b6d8abc90fa29d665b6d88e39" href="/guides/playwright-github-actions" width="800" height="800" data-path="images/github-svgrepo-com.svg" />

    <Card title="GitLab" img="https://mintcdn.com/testdino/_W5tZrChGQAb05lF/images/gitlab-logo-500-rgb.svg?fit=max&auto=format&n=_W5tZrChGQAb05lF&q=85&s=0fdfd890fe016b0d6cff99fad0a21684" href="/guides/playwright-gitlab-ci-setup" width="256" height="256" data-path="images/gitlab-logo-500-rgb.svg" />

    <Card title="TeamCity" img="https://mintcdn.com/testdino/_W5tZrChGQAb05lF/images/teamcity-icon.svg?fit=max&auto=format&n=_W5tZrChGQAb05lF&q=85&s=eb2a564c91dcf59db6018127d8103797" href="/guides/playwright-teamcity" width="256" height="256" data-path="images/teamcity-icon.svg" />

    <Card title="Azure DevOps" img="https://mintcdn.com/testdino/JwytUEY7x2_fx041/images/azure-devops.svg?fit=max&auto=format&n=JwytUEY7x2_fx041&q=85&s=f8982ec615ae9abd45220ccf3d31d1fd" href="/guides/playwright-azure-devops-pipeline" width="32" height="32" data-path="images/azure-devops.svg" />

    <Card title="CircleCI" img="https://mintcdn.com/testdino/Ua7R4RmzUY5yacWr/images/Circleci-icon-logo.svg?fit=max&auto=format&n=Ua7R4RmzUY5yacWr&q=85&s=a0c70425c249f47ebccd93e7b89aa6bd" href="/guides/playwright-circle-ci-orb" width="104" height="105" data-path="images/Circleci-icon-logo.svg" />

    <Card title="AWS CodeBuild" img="https://mintcdn.com/testdino/Ua7R4RmzUY5yacWr/images/CodeBuild.svg?fit=max&auto=format&n=Ua7R4RmzUY5yacWr&q=85&s=3182ba12e600efaee867fd7448edeeef" href="/guides/playwright-amazon-codebuild" width="80" height="80" data-path="images/CodeBuild.svg" />

    <Card title="Jenkins" img="https://mintcdn.com/testdino/Ua7R4RmzUY5yacWr/images/jenkins.svg?fit=max&auto=format&n=Ua7R4RmzUY5yacWr&q=85&s=e73a6fd9932bc067d6c2cc2d5e898e61" href="/guides/playwright-jenkins" width="800" height="800" data-path="images/jenkins.svg" />
  </CardGroup>
</div>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Token is required but not provided">
    Set the token via `--token`, the `TESTDINO_TOKEN` environment variable, or the reporter option in `playwright.config`. Confirm it is set:

    ```bash theme={null}
    echo $TESTDINO_TOKEN
    ```

    Generate a new token from [API Keys](/guides/generate-api-keys) if the issue persists.
  </Accordion>

  <Accordion title="Execution limit reached">
    Your account reached its monthly quota. Tests continue to run normally. Only streaming to TestDino pauses until the quota resets.

    Upgrade your plan or wait for the monthly reset.
  </Accordion>

  <Accordion title="Stream dropped, switched to HTTP fallback">
    Expected behavior. If the streaming connection drops, events fall back to HTTP delivery automatically. Your tests are never affected.
  </Accordion>

  <Accordion title="Enable debug logging">
    ```bash theme={null}
    npx tdpw test --debug
    ```
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Real-Time Test Streaming" icon="bolt" href="/guides/playwright-real-time-test-streaming">
    How real-time streaming works and when to use it
  </Card>

  <Card title="Generate API Keys" icon="key" href="/guides/generate-api-keys">
    Create and manage tokens for the CLI and CI
  </Card>
</CardGroup>
