tdpw
Version:
CLI tool for uploading Playwright test reports to TestDino platform with TestDino storage support
304 lines (220 loc) • 8.25 kB
Markdown
# tdpw
[](https://www.npmjs.com/package/tdpw)
[](https://nodejs.org/)
[](https://opensource.org/licenses/MIT)
> 🦕 **TestDino CLI** - Cache test metadata and upload Playwright test reports to TestDino platform
## 🚀 Quick Start
### Cache Command
```bash
# Cache test execution metadata after Playwright runs
npx tdpw cache --token="your-api-token"
# With verbose logging
npx tdpw cache --verbose
```
### Last Failed Command
```bash
# Get last failed test cases for Playwright reruns
npx tdpw last-failed --token="your-api-token"
# Run only last failed tests
npx playwright test $(npx tdpw last-failed --token="your-api-token")
```
### Upload Command
```bash
# 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
```
## 📦 Installation
### NPX
```bash
npx tdpw <command> --token="your-token"
```
### Global Installation
```bash
npm install -g tdpw
tdpw <command> --token="your-token"
```
### Project Dependency
```bash
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, Azure DevOps
- ✅ **Secure Authentication** - Token-based API authentication
## 📖 Commands
### Cache Command
Store test execution metadata after Playwright runs.
```bash
# Basic usage
npx tdpw cache --token="your-token"
# With 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, --verbose` | Enable verbose logging | `false` |
### Last Failed Command
Retrieve cached test failures for intelligent reruns.
```bash
# Basic usage
npx tdpw last-failed --token="your-token"
# Run only last failed tests
npx playwright test $(npx tdpw last-failed --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 |
| `-t, --token <value>` | TestDino API token | Required |
| `-v, --verbose` | Enable verbose logging | `false` |
### Upload Command
Upload test reports with attachments.
```bash
# Basic upload
npx tdpw upload ./playwright-report --token="your-token"
# Upload with 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 | Default |
| ----------------------- | ------------------------------------------------------ | --------- |
| `<report-directory>` | Directory containing Playwright reports | Required |
| `-t, --token <value>` | TestDino API token | Required |
| `--environment <value>` | Target environment tag (e.g., staging, production, qa) | `unknown` |
| `--upload-images` | Upload image attachments | `false` |
| `--upload-videos` | Upload video attachments | `false` |
| `--upload-html` | Upload HTML reports | `false` |
| `--upload-traces` | Upload trace files | `false` |
| `--upload-files` | Upload file attachments (.md, .pdf, .txt, .log) | `false` |
| `--upload-full-json` | Upload all attachments | `false` |
| `-v, --verbose` | Enable verbose logging | `false` |
### Environment Variables
```bash
export TESTDINO_TOKEN="your-api-token"
export TESTDINO_API_URL="https://api.testdino.com" # Optional: Custom API endpoint
export TESTDINO_TARGET_ENV="staging" # Optional: Target environment for Testrun
```
## 🔧 CI/CD Integration
### GitHub Actions
```yaml
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
```
### GitLab CI
```yaml
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
```
### Jenkins
```groovy
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
### Getting Your Token
1. Sign up at [TestDino](https://app.testdino.com)
2. Navigate to **Settings** → **API Tokens**
3. Generate a new token
4. Store it securely in your CI/CD secrets
**Token Format:**
```
trx_{environment}_{64-character-hex-string}
```
**Security Best Practices:**
- Never commit tokens to version control
- Use environment variables or CI/CD secrets
- Rotate tokens regularly
## 🎭 Examples
### Basic Workflow
```bash
# Run tests and cache metadata
npx playwright test
npx tdpw cache --token="your-token"
```
### Intelligent Test Reruns
```bash
# Run tests and cache results
npx playwright test
npx tdpw cache --token="your-token"
# On next run, execute only previously failed tests
npx playwright test $(npx tdpw last-failed --token="your-token")
```
### Complete CI/CD Workflow
```bash
# Run all tests
npx playwright test
# Cache test metadata
npx tdpw cache --token="$TESTDINO_TOKEN"
# Rerun only failed tests
if [ $? -ne 0 ]; then
FAILED=$(npx tdpw last-failed --token="$TESTDINO_TOKEN")
[ -n "$FAILED" ] && npx playwright test $FAILED
fi
```
## 🆘 Support
- 📖 **Documentation**: [docs.testdino.com](https://docs.testdino.com)
- 🐛 **Issues**: [GitHub Issues](https://github.com/testdino-inc/testdino-cli/issues)
- 📧 **Email**: support@testdino.com
---
**Made with ❤️ by the [TestDino](https://testdino.com) team**