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
Upload the report
npx tdpw upload ./playwright-report --token= "your-token"
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.
npx (Recommended)
Global Installation
Dev Dependency
No installation needed. Just run: npx tdpw < comman d > --token= "your-token"
Install globally: Then run: tdpw < comman d > --token= "your-token"
Install as a dev dependency: npm install --save-dev tdpw
Then use in package.json scripts or run with npx.
Common Workflows
1. Cache metadata after a run
2. Rerun only failed tests
Print failed tests: npx tdpw last-failed --token= "your-token"
Run only failed tests: npx playwright test $( npx tdpw last-failed --token= "your-token" )
3. Upload reports and artifacts
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
4. Complete CI/CD workflow
Run all tests: 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
Option Description Default --working-dir <path>Directory to scan for test results Current directory --cache-id <value>Custom cache ID override Auto detected -t, --token <value>TestDino API token Required -v, --verboseEnable verbose logging false
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
Option Description Default --cache-id <value>Custom cache ID override Auto detected --branch <value>Custom branch name override Auto detected --commit <value>Custom commit hash override Auto detected --shard <value>Shard specification (e.g., “2/5” for shard 2 of 5) None --environment <value>Environment name for filtering tests None -t, --token <value>TestDino API token Required -v, --verboseEnable verbose logging false
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
Option Description <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 Actions
GitLab CI
Jenkins
.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
image : node:18
stages :
- test
playwright-tests :
stage : test
script :
- npm ci
- npx playwright install --with-deps
- npx playwright test
- npx tdpw upload ./playwright-report --token="$TESTDINO_TOKEN" --upload-full-json
when : always
pipeline {
agent any
environment {
TESTDINO_TOKEN = credentials( 'testdino-token' )
}
stages {
stage( 'Test' ) {
steps {
sh 'npm ci'
sh 'npx playwright install --with-deps'
sh 'npx playwright test'
sh 'npx tdpw upload ./playwright-report --token="$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