TestDino CLI
Node.js (tdpw)

Node.js CLI (tdpw)

tdpw (TestDino Playwright) is the TestDino CLI for Node-based projects.

It caches test metadata, retrieves last failed tests, and uploads Playwright reports to the TestDino platform.

1. Package and Platform Information

2. When to Use tdpw

  • Pick tdpw if your Playwright tests run on Node.js.

  • It integrates with existing JavaScript or TypeScript projects without additional configuration.

  • The CLI auto-discovers your Playwright reports and handles uploads in a single command.

3. Prerequisites

  • Node.js is installed on your machine

  • An existing Playwright test suite

  • A TestDino account with an API token

Quick Start

1. Cache command (basic)

Cache test execution metadata after Playwright runs:

npx tdpw cache --token="your-api-token"

With verbose logging:

npx tdpw cache --verbose

2. Last failed command (basic)

Fetch last failed tests and rerun only those tests:

Print last failed tests

npx tdpw last-failed --token="your-api-token"

Run only the last failed tests

npx playwright test $(npx tdpw last-failed --token="your-api-token")

3. Upload command (basic)

Upload Playwright reports and attachments to TestDino:

Upload test reports with attachments

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

Upload all attachments

npx tdpw upload ./playwright-report --token="your-api-token" --upload-full-json

4. Five Minute Tutorial

Here's how to get started:

1. Install Dependencies

Install your project dependencies and Playwright browsers.

2. Run Tests

Run your Playwright tests so that a report directory (such as ./playwright-report) is generated.

3. Upload Reports

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

4. Cache Metadata

npx tdpw cache --token="your-token"

5. View Results

Open TestDino to view your test run.

Installation

You can run tdpw in three ways.

1. Run with npx

No installation needed. Just run:

npx tdpw <command> --token="your-token"

2. Global Installation

npm install -g tdpw

Then run:

tdpw <command> --token="your-token"

3. Project Dev Dependency

npm install --save-dev tdpw

Features

  • Test Metadata Caching: Store test execution metadata after Playwright runs

  • Last Failed Tests: Retrieve and rerun only failed tests for faster CI/CD pipelines

  • Zero Configuration: Auto-discovers Playwright reports and configuration

  • Smart Shard Detection: Automatically detects Playwright shard information

  • CI/CD Ready: Works seamlessly with GitHub Actions, GitLab CI, Jenkins, and Azure DevOps

  • Secure Authentication: Token-based API authentication

Commands

1. Cache Command

Store test execution metadata after Playwright runs. This data powers the last-failed command and feeds into TestDino analytics.

1.1 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"

1.2 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 Command

Retrieve cached test failures for intelligent reruns. This command outputs test identifiers that you can pass directly to Playwright.

2.1 Usage

Basic usage:

npx tdpw last-failed --token="your-token"

Run only the last failed tests:

npx playwright test $(npx tdpw last-failed --token="your-token")

With a custom branch and commit:

npx tdpw last-failed --branch="main" --commit="abc123" --token="your-token"

2.2 Options

OptionDescriptionDefault
--cache-id <value>Custom cache ID overrideAuto detected
--branch <value>Custom branch name overrideAuto detected
--commit <value>Custom commit hash overrideAuto detected
-t, --token <value>TestDino API tokenRequired
-v, --verboseEnable verbose loggingfalse

3. Upload Command

Upload Playwright test reports and attachments to TestDino.

This command sends your report directory to the platform, including screenshots, videos, traces, and other artifacts based on the flags you set.

3.1 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

3.2 Options

OptionDescription
<report-directory>Directory containing Playwright reports (required)
-t, --token <value>TestDino API token (required)
--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

4. Environment Variables

You can set your token as an environment variable instead of passing it with each command:

export TESTDINO_TOKEN="your-api-token"

For custom API endpoints:

export TESTDINO_API_URL="https://api.testdino.com"

CI/CD Integration

1. GitHub Actions

.github/workflows/test.yml
name: Playwright Tests
on: [push, pull_request]
 
jobs:
  test:
    runs-on: ubuntu-latest
    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 tests
        run: npx playwright test
 
      - name: Upload test reports
        if: always()
        run: npx tdpw upload ./playwright-report --token="${{ secrets.TESTDINO_TOKEN }}" --upload-full-json

2. GitLab CI

.gitlab-ci.yml
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

3. Jenkins

Jenkinsfile
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'
            }
        }
    }
}

Examples

1. Basic Workflow

Run tests and cache metadata:

npx playwright test
npx tdpw cache --token="your-token"

2. Intelligent Test Reruns

Run tests and cache results:

npx playwright test
npx tdpw cache --token="your-token"

On the next run, execute only previously failed tests:

npx playwright test $(npx tdpw last-failed --token="your-token")

3. Complete CI/CD Workflow

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

Authentication

1. Getting Your Token

  • Create an account at TestDino (app.testdino.com).

  • Go to Settings, then API Tokens.

  • Generate a new token.

  • Store it securely in your CI/CD secrets.

2. Security Best Practices

  • Never commit tokens to version control

  • Use environment variables or CI/CD secrets

  • Rotate tokens regularly