Playwright Integration
Run your Playwright tests as usual and have results, screenshots, and traces automatically reported to ProvaLab.io.
Install
npm install tms-node-sdk
Requirements: Node.js >= 18.0.0, Playwright >= 1.30.0
Configure
1. Set environment variables
export TMS_API_KEY=your-api-key
export TMS_API_URL=https://tms.yourcompany.com
export TMS_ORGANIZATION_ID=1
export TMS_PROJECT_ID=12
Or create a .env file in your project root:
TMS_API_KEY=your-api-key
TMS_API_URL=https://tms.yourcompany.com
TMS_ORGANIZATION_ID=1
TMS_PROJECT_ID=12
TMS_ENVIRONMENT=staging
2. Add the ProvaLab.io reporter to your Playwright config
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
reporter: [
['list'], // Keep the default console output
['tms-node-sdk/playwright/reporter'], // Add ProvaLab.io reporting
],
use: {
screenshot: 'only-on-failure', // ProvaLab.io auto-uploads failure screenshots
trace: 'on-first-retry',
},
});
That's it. Every time you run tests, results go to ProvaLab.io automatically.
Run
npx playwright test
You'll see ProvaLab.io output alongside Playwright's normal output:
========================================
ProvaLab.io Playwright Integration
========================================
Test Run ID: 847
Project ID: 12
Organization ID: 1
Tests discovered: 15
========================================
[PASS] should display homepage (1.24s)
[PASS] should navigate to login (0.89s)
[FAIL] should submit contact form (2.31s)
========================================
ProvaLab.io Test Run Summary
========================================
Test Run ID: 847
Total: 3
Passed: 2
Failed: 1
Skipped: 0
Status: FAILED
========================================
View Results in ProvaLab.io
- Open ProvaLab.io and go to your project
- Click Test Runs in the sidebar
- Find the run named "Playwright: 2026-02-20 14:30:00" (or your custom name)
- Click into it to see individual test results, screenshots, and logs
Link Tests to ProvaLab.io Test Cases
Option 1: Include the ID in the test title
import { test, expect } from '@playwright/test';
test('[TMS-101] should display login page', async ({ page }) => {
await page.goto('/login');
await expect(page.locator('h1')).toHaveText('Login');
});
test('[TMS-102] should login with valid credentials', async ({ page }) => {
await page.goto('/login');
await page.fill('#email', '[email protected]');
await page.fill('#password', 'password123');
await page.click('button[type="submit"]');
await expect(page).toHaveURL('/dashboard');
});
Option 2: Use a mapping file
Create test-case-mapping.json in your project root:
{
"should display login page": { "id": 101, "priority": "high", "type": "smoke" },
"should login with valid credentials": { "id": 102, "priority": "critical", "type": "e2e" }
}
Then set the environment variable:
export TMS_MAPPING_FILE=test-case-mapping.json
Advanced Configuration
Custom test run name
export TMS_TEST_RUN_NAME="Nightly E2E - Chrome"
Screenshot on failure
Playwright's built-in screenshot capture works seamlessly with ProvaLab.io. When a test fails and has a screenshot attachment, ProvaLab.io uploads it automatically.
export default defineConfig({
use: {
screenshot: 'only-on-failure', // ProvaLab.io will upload these automatically
video: 'retain-on-failure',
trace: 'on-first-retry',
},
reporter: [
['list'],
['tms-node-sdk/playwright/reporter'],
],
});
Disable ProvaLab.io for local development
export TMS_DISABLED=true
npx playwright test
The reporter gracefully skips all ProvaLab.io operations when disabled.
Retry and timeout settings
export TMS_REQUEST_TIMEOUT_MS=30000 # HTTP request timeout (default: 30s)
export TMS_MAX_RETRIES=3 # Retry failed API calls (default: 3)
The SDK includes a circuit breaker that temporarily stops sending requests to ProvaLab.io if the API is unreachable. Your tests keep running normally -- ProvaLab.io reporting resumes automatically when the API recovers. After 5 consecutive failures, the circuit opens for 30 seconds before retrying.
QA Infrastructure (Remote Browsers)
If your organization uses ProvaLab.io QA Infrastructure for remote browser sessions, the Playwright reporter can automatically provision browsers:
export QA_INFRA_URL=https://qa-infra.yourcompany.com
export QA_INFRA_API_KEY=your-infra-key
When configured, each test gets a dedicated remote browser session with video recording and VNC streaming.
Verify It Works
- Set your environment variables
- Create a simple test:
import { test, expect } from '@playwright/test';
test('[TMS-1] verify TMS integration', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Example/);
});
- Run it:
npx playwright test tests/tms-verify.spec.ts
- Check the console output for the ProvaLab.io banner with a Test Run ID
- Open ProvaLab.io and confirm the test run appears under your project
- "Not configured" message: Make sure
TMS_API_KEY,TMS_ORGANIZATION_ID, andTMS_PROJECT_IDare all set - "Failed to create test run": Verify your API key is valid and has write access to the project
- Results not appearing: Check that
TMS_API_URLpoints to your ProvaLab.io instance (notlocalhostunless running locally)