Playwright TestRail Reporter

1.3.3 · active · verified Tue Apr 21

The `playwright-testrail-reporter` is a custom reporter designed to integrate Playwright Test results seamlessly with TestRail. It automates the process of creating new TestRail runs or updating existing ones, and then posts test outcomes by matching specific case IDs (e.g., `C12345`) embedded directly within Playwright test titles. The current stable version is 1.3.3, released in October 2025, with a consistent cadence of minor quality-of-life improvements and dependency updates. Key differentiators include robust environment variable validation and auto-sanitization, support for using TestRail API keys instead of passwords, and flexible custom status mappings for different test outcomes. It simplifies the reporting workflow, allowing developers to focus on writing tests rather than manually updating TestRail.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure `playwright-testrail-reporter` in `playwright.config.ts` and tag tests with TestRail case IDs (e.g., C12345) for automatic reporting. It also highlights the necessary environment variables for TestRail integration.

import { defineConfig } from '@playwright/test';

// To ensure environment variables are loaded if using a .env file
// require('dotenv').config(); // Uncomment if you are using dotenv

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: [
    ['list'], // Keep the default list reporter
    ['playwright-testrail-reporter'] // Add TestRail reporter
  ],
  use: {
    baseURL: 'http://127.0.0.1:3000',
    trace: 'on-first-retry',
  },
});

// Example test file (tests/example.spec.ts)
// Make sure to set these environment variables in your .env file:
// TESTRAIL_HOST=https://yourcompany.testrail.io
// TESTRAIL_USERNAME=your.email@company.com
// TESTRAIL_API_KEY=your_api_key_here
// TESTRAIL_PROJECT_ID=123
// TESTRAIL_SUITE_ID=456
// TESTRAIL_RUN_NAME=Automated Playwright Run

import { test, expect } from '@playwright/test';

test('C12345: User can log in with valid credentials', async ({ page }) => {
  await page.goto('/');
  // Simulate login
  console.log('Test C12345 executed.');
  expect(true).toBe(true);
});

test('C67890 C98765: Dashboard loads correctly after login', async ({ page }) => {
  await page.goto('/dashboard');
  // Simulate dashboard checks
  console.log('Test C67890 and C98765 executed.');
  expect(page.url()).toContain('/dashboard');
});

view raw JSON →