Skip to main content
tdpw caches test metadata, retrieves last failed tests, and uploads Playwright reports to the TestDino platform.

Prerequisites

  • tdpw npm package version 1.0.26+
  • Node.js >= 18.0.0
  • Playwright test suite
  • TestDino API token
  • Git initialized repository (required for commit and branch metadata)

Quick Start Steps

Run your Playwright tests first to create a report directory, for example, ./playwright-report
1

Upload the report

npx tdpw upload ./playwright-report --token="your-token"
2

Cache test execution metadata

Cache test execution metadata after Playwright runs, and view your test run in TestDino:
npx tdpw cache --token="your-token"

Installation

You can run tdpw in any of these ways.

Common Workflows

Run tests and cache metadata:
npx playwright test
npx tdpw cache --token="your-token"
Print failed tests:
npx tdpw last-failed --token="your-token"
Run only failed tests:
npx playwright test $(npx tdpw last-failed --token="your-token")
Upload the report directory:
npx tdpw upload ./playwright-report --token="your-token"
Upload all supported attachments:
npx tdpw upload ./playwright-report --token="your-token" --upload-full-json
Run all tests:
npx playwright test
Cache test metadata:
npx tdpw cache --token="$TESTDINO_TOKEN"
Rerun only failed tests if the first run had failures:
if [ $? -ne 0 ]; then
  FAILED=$(npx tdpw last-failed --token="$TESTDINO_TOKEN")
  [ -n "$FAILED" ] && npx playwright test $FAILED
fi

Commands

1. cache

Store test execution metadata after Playwright runs. This data powers the last-failed command and feeds into TestDino analytics. Usage Basic usage:
npx tdpw cache --token="your-token"
With a custom working directory:
npx tdpw cache --working-dir ./test-results --token="your-token"
With verbose logging:
npx tdpw cache --verbose --token="your-token"
Options
OptionDescriptionDefault
--working-dir <path>Directory to scan for test resultsCurrent directory
--cache-id <value>Custom cache ID overrideAuto detected
-t, --token <value>TestDino API tokenRequired
-v, --verboseEnable verbose loggingfalse

2. last-failed

Retrieve cached test failures for intelligent reruns. This command outputs test identifiers that you can pass directly to Playwright. Usage Basic usage:
npx tdpw last-failed --token="your-token"
Run only failed tests:
npx playwright test $(npx tdpw last-failed --token="your-token")
Get failed tests for specific shard:
npx tdpw last-failed --shard="2/5" --token="your-token"
With custom branch and commit:
npx tdpw last-failed --branch="main" --commit="abc123" --token="your-token"
Options
OptionDescriptionDefault
--cache-id <value>Custom cache ID overrideAuto detected
--branch <value>Custom branch name overrideAuto detected
--commit <value>Custom commit hash overrideAuto detected
--shard <value>Shard specification (e.g., “2/5” for shard 2 of 5)None
--environment <value>Environment name for filtering testsNone
-t, --token <value>TestDino API tokenRequired
-v, --verboseEnable verbose loggingfalse

3. upload <report-directory>

Upload a Playwright report directory to TestDino. Attachments include screenshots, videos, traces, and other artifacts based on flags. Usage Basic upload:
npx tdpw upload ./playwright-report --token="your-token"
Upload with specific attachments:
npx tdpw upload ./playwright-report --token="your-token" --upload-images --upload-videos
Upload all attachments:
npx tdpw upload ./playwright-report --token="your-token" --upload-full-json
Upload with target environment tag:
npx tdpw upload ./playwright-report --token="your-token" --environment="staging"
Options
OptionDescription
<report-directory>Directory containing Playwright reports (required)
-t, --token <value>TestDino API token (required)
--environment <value>Target environment tag (e.g., staging, production, qa)
--upload-imagesUpload image attachments
--upload-videosUpload video attachments
--upload-htmlUpload HTML reports
--upload-tracesUpload trace files
--upload-filesUpload file attachments (.md, .pdf, .txt, .log)
--upload-full-jsonUpload all attachments
-v, --verboseEnable verbose logging

Environment Variables

Set the token once:
export TESTDINO_TOKEN="your-api-token"
Set a custom API endpoint:
export TESTDINO_API_URL="https://api.testdino.com"
Set a default environment tag:
export TESTDINO_TARGET_ENV="staging"

CI/CD Integration

.github/workflows/test.yml
name: Playwright Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '18'

      - name: Install dependencies
        run: npm ci

      - name: Install Playwright
        run: npx playwright install --with-deps

      - name: Run Playwright Tests
        shell: bash
        env:
          TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
          SHARD_INDEX: ${{ matrix.shardIndex }}
          SHARD_TOTAL: ${{ matrix.shardTotal }}
        run: |
          echo "GitHub run attempt: ${{ github.run_attempt }}"
          # Case 1: Re-run failed jobs → run only failed tests
          if [[ "${{ github.run_attempt }}" -gt 1 ]]; then
            echo "Detected re-run. Executing only last failed tests via TestDino."
            
            npx tdpw last-failed --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} > last-failed-flags.txt
            EXTRA_PW_FLAGS="$(cat last-failed-flags.txt)"
            
            if [[ -z "$EXTRA_PW_FLAGS" ]]; then
              echo "No failed tests found. Exiting."
              exit 0
            fi
            
            echo "Running failed tests without sharding:"
            echo "$EXTRA_PW_FLAGS"
            
            # IMPORTANT: preserve quotes
            eval "npx playwright test $EXTRA_PW_FLAGS"
            exit 0
          fi
          
          # Case 2: Normal execution (first run)
          echo "Running all Playwright tests"
          npx playwright test \
            --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

      - name: Cache rerun metadata
        if: always()
        run: npx tdpw cache --token="${{ secrets.TESTDINO_TOKEN }}"

      - name: Upload test reports
        if: always()
        run: npx tdpw upload ./playwright-report --token="${{ secrets.TESTDINO_TOKEN }}" --upload-full-json

Authentication

Get a token from the TestDino app and store it as a secret.
  • Generate an API token in the TestDino settings
  • Store it in CI secrets
  • Do not commit tokens to version control
  • Rotate tokens on a regular schedule