{"id":15367,"library":"playwright-testrail-reporter","title":"Playwright TestRail Reporter","description":"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.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/niche-tester/playwright-testrail-reporter","tags":["javascript","playwright","testrail","reporter","reporter-testrail","playwright-testrail","typescript"],"install":[{"cmd":"npm install playwright-testrail-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add playwright-testrail-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add playwright-testrail-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Playwright Test integration as a peer dependency.","package":"@playwright/test","optional":false}],"imports":[{"note":"The reporter is integrated into Playwright's configuration by providing its package name as a string in the `reporter` array within `playwright.config.ts`, not by importing a specific class or function.","wrong":"import { TestRailReporter } from 'playwright-testrail-reporter';","symbol":"playwright-testrail-reporter","correct":"['playwright-testrail-reporter']"},{"note":"Standard Playwright configuration helper. Playwright config files (`playwright.config.ts`) are typically run as ESM.","wrong":"const defineConfig = require('@playwright/test').defineConfig;","symbol":"defineConfig","correct":"import { defineConfig } from '@playwright/test';"}],"quickstart":{"code":"import { defineConfig } from '@playwright/test';\n\n// To ensure environment variables are loaded if using a .env file\n// require('dotenv').config(); // Uncomment if you are using dotenv\n\nexport default defineConfig({\n  testDir: './tests',\n  fullyParallel: true,\n  forbidOnly: !!process.env.CI,\n  retries: process.env.CI ? 2 : 0,\n  workers: process.env.CI ? 1 : undefined,\n  reporter: [\n    ['list'], // Keep the default list reporter\n    ['playwright-testrail-reporter'] // Add TestRail reporter\n  ],\n  use: {\n    baseURL: 'http://127.0.0.1:3000',\n    trace: 'on-first-retry',\n  },\n});\n\n// Example test file (tests/example.spec.ts)\n// Make sure to set these environment variables in your .env file:\n// TESTRAIL_HOST=https://yourcompany.testrail.io\n// TESTRAIL_USERNAME=your.email@company.com\n// TESTRAIL_API_KEY=your_api_key_here\n// TESTRAIL_PROJECT_ID=123\n// TESTRAIL_SUITE_ID=456\n// TESTRAIL_RUN_NAME=Automated Playwright Run\n\nimport { test, expect } from '@playwright/test';\n\ntest('C12345: User can log in with valid credentials', async ({ page }) => {\n  await page.goto('/');\n  // Simulate login\n  console.log('Test C12345 executed.');\n  expect(true).toBe(true);\n});\n\ntest('C67890 C98765: Dashboard loads correctly after login', async ({ page }) => {\n  await page.goto('/dashboard');\n  // Simulate dashboard checks\n  console.log('Test C67890 and C98765 executed.');\n  expect(page.url()).toContain('/dashboard');\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Rename `TESTRAIL_PASSWORD` to `TESTRAIL_API_KEY` in your `.env` file and provide a TestRail API key instead of a regular user password.","message":"The environment variable `TESTRAIL_PASSWORD` is deprecated. Using it will result in a warning message in the console.","severity":"deprecated","affected_versions":">=1.3.0"},{"fix":"Upgrade to `playwright-testrail-reporter@1.3.3` or newer, which includes smart environment variable validation and auto-sanitization. Always ensure `TESTRAIL_HOST` includes `https://` and IDs are numeric.","message":"Prior to v1.3.3, incorrect or malformed environment variables (e.g., missing `https://` in `TESTRAIL_HOST`, or non-numeric IDs) could lead to runtime errors like `AggregateError` or 'TestRail Run ID: NaN'.","severity":"gotcha","affected_versions":"<1.3.3"},{"fix":"Generate an API key in your TestRail 'My Settings' and use that for the `TESTRAIL_API_KEY` environment variable.","message":"It is critical to use your TestRail API key for `TESTRAIL_API_KEY`, not your regular login password. Using the password may lead to authentication failures or unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add `TESTRAIL_STATUS_SKIPPED=6` (or your custom skipped status ID) to your `.env` file.","message":"For Playwright to report skipped tests to TestRail, you must explicitly define `TESTRAIL_STATUS_SKIPPED` in your environment variables, as it does not have a default mapping.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `TESTRAIL_HOST` (including `https://`), `TESTRAIL_USERNAME`, `TESTRAIL_API_KEY`, `TESTRAIL_PROJECT_ID`, and `TESTRAIL_SUITE_ID` are correctly set and formatted in your `.env` file. Upgrade to `v1.3.3` or higher for automatic sanitization.","cause":"Malformed or missing environment variables for TestRail configuration, or non-numeric values for ID variables.","error":"AggregateError: Multiple errors occurred..."},{"fix":"Verify `TESTRAIL_HOST`, `TESTRAIL_USERNAME`, and `TESTRAIL_API_KEY` are accurate and have the necessary permissions. Double-check for typos and ensure `TESTRAIL_HOST` includes `https://`.","cause":"TestRail API key, host, or user credentials are incorrect, leading to authentication or API errors when creating/updating runs.","error":"playwright-testrail-reporter] ℹ️  No existing 'TESTRAIL_RUN_ID' provided by user. Creating a new TestR... [playwright-testrail-reporter] ❌ Error: Test results could not be added. Check TestRail configuration."},{"fix":"Add TestRail case IDs in the format `C12345` to your Playwright test names. Ensure `['playwright-testrail-reporter']` is present in the `reporter` array within your `playwright.config.ts`.","cause":"Test cases in Playwright are not tagged with TestRail case IDs (e.g., C12345), or the `playwright-testrail-reporter` is not correctly configured in `playwright.config.ts`.","error":"No test results appearing in TestRail after a Playwright test run completes."}],"ecosystem":"npm"}