TestRail Integration

Sync tests with TestRail.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/testrail, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/testrail#main ~/.claude/skills/testrail

For one project only, change the path to .claude/skills/testrail. This skill also uses test-results.json — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of TestRail Integration

Show the full text138 lines
namedescription
testrail>- Sync tests with TestRail. Use when user mentions "testrail", "test management", test cases", "test run", "sync test cases", "push results to testrail", or "import from testrail".

TestRail Integration

Bidirectional sync between Playwright tests and TestRail test management.

Prerequisites

Environment variables must be set:

  • TESTRAIL_URL — e.g., https://your-instance.testrail.io
  • TESTRAIL_USER — your email
  • TESTRAIL_API_KEY — API key from TestRail

If not set, inform the user how to configure them and stop.

The TestRail MCP server is not auto-registered (issue #978). pw-testrail was removed from the plugin's .mcp.json because it failed to connect for every user (the plugin ships no node_modules). The testrail_* MCP tools used below, and the /pw:testrail command, will fail with "tool not found" until it is enabled manually — see the Integrations section of the plugin's CLAUDE.md (cd integrations/testrail-mcp && npm install, then register the server in your own user/project MCP config). Setting the env vars alone is not sufficient.

Capabilities

1. Import Test Cases → Generate Playwright Tests
/pw:testrail import --project <id> --suite <id>

Steps:

  1. Call testrail_get_cases MCP tool to fetch test cases
  2. For each test case:
    • Read title, preconditions, steps, expected results
    • Map to a Playwright test using appropriate template
    • Include TestRail case ID as test annotation: test.info().annotations.push({ type: 'testrail', description: 'C12345' })
  3. Generate test files grouped by section
  4. Report: X cases imported, Y tests generated
2. Push Test Results → TestRail
/pw:testrail push --run <id>

Steps:

  1. Run Playwright tests with JSON reporter:
    npx playwright test --reporter=json > test-results.json
    
  2. Parse results: map each test to its TestRail case ID (from annotations)
  3. Call testrail_add_result MCP tool for each test:
    • Pass → status_id: 1
    • Fail → status_id: 5, include error message
    • Skip → status_id: 2
  4. Report: X results pushed, Y passed, Z failed
3. Create Test Run
/pw:testrail run --project <id> --name "Sprint 42 Regression"

Steps:

  1. Call testrail_add_run MCP tool
  2. Include all test case IDs found in Playwright test annotations
  3. Return run ID for result pushing
4. Sync Status
/pw:testrail status --project <id>

Steps:

  1. Fetch test cases from TestRail
  2. Scan local Playwright tests for TestRail annotations
  3. Report coverage:
    TestRail cases: 150
    Playwright tests with TestRail IDs: 120
    Unlinked TestRail cases: 30
    Playwright tests without TestRail IDs: 15
    
5. Update Test Cases in TestRail
/pw:testrail update --case <id>

Steps:

  1. Read the Playwright test for this case ID
  2. Extract steps and expected results from test code
  3. Call testrail_update_case MCP tool to update steps

MCP Tools Used

Tool When
testrail_get_projects List available projects
testrail_get_suites List suites in project
testrail_get_cases Read test cases
testrail_add_case Create new test case
testrail_update_case Update existing case
testrail_add_run Create test run
testrail_add_result Push individual result
testrail_get_results Read historical results

Test Annotation Format

All Playwright tests linked to TestRail include:

test('should login successfully', async ({ page }) => {
  test.info().annotations.push({
    type: 'testrail',
    description: 'C12345',
  });
  // ... test code
});

This annotation is the bridge between Playwright and TestRail.

Output

  • Operation summary with counts
  • Any errors or unmatched cases
  • Link to TestRail run/results
1---
2name: "testrail"
3description: >-
4 Sync tests with TestRail. Use when user mentions "testrail", "test management",
5 "test cases", "test run", "sync test cases", "push results to testrail",
6 or "import from testrail".
7---
8 
9# TestRail Integration
10 
11Bidirectional sync between Playwright tests and TestRail test management.
12 
13## Prerequisites
14 
15Environment variables must be set:
16- `TESTRAIL_URL` — e.g., `https://your-instance.testrail.io`
17- `TESTRAIL_USER` — your email
18- `TESTRAIL_API_KEY` — API key from TestRail
19 
20If not set, inform the user how to configure them and stop.
21 
22> **The TestRail MCP server is not auto-registered (issue #978).** `pw-testrail`
23> was removed from the plugin's `.mcp.json` because it failed to connect for every
24> user (the plugin ships no `node_modules`). The `testrail_*` MCP tools used below,
25> and the `/pw:testrail` command, will fail with "tool not found" until it is
26> enabled manually — see the **Integrations** section of the plugin's `CLAUDE.md`
27> (`cd integrations/testrail-mcp && npm install`, then register the server in your
28> own user/project MCP config). Setting the env vars alone is not sufficient.
29 
30## Capabilities
31 
32### 1. Import Test Cases → Generate Playwright Tests
33 
34```
35/pw:testrail import --project <id> --suite <id>
36```
37 
38Steps:
391. Call `testrail_get_cases` MCP tool to fetch test cases
402. For each test case:
41 - Read title, preconditions, steps, expected results
42 - Map to a Playwright test using appropriate template
43 - Include TestRail case ID as test annotation: `test.info().annotations.push({ type: 'testrail', description: 'C12345' })`
443. Generate test files grouped by section
454. Report: X cases imported, Y tests generated
46 
47### 2. Push Test Results → TestRail
48 
49```
50/pw:testrail push --run <id>
51```
52 
53Steps:
541. Run Playwright tests with JSON reporter:
55 ```bash
56 npx playwright test --reporter=json > test-results.json
57 ```
582. Parse results: map each test to its TestRail case ID (from annotations)
593. Call `testrail_add_result` MCP tool for each test:
60 - Pass → status_id: 1
61 - Fail → status_id: 5, include error message
62 - Skip → status_id: 2
634. Report: X results pushed, Y passed, Z failed
64 
65### 3. Create Test Run
66 
67```
68/pw:testrail run --project <id> --name "Sprint 42 Regression"
69```
70 
71Steps:
721. Call `testrail_add_run` MCP tool
732. Include all test case IDs found in Playwright test annotations
743. Return run ID for result pushing
75 
76### 4. Sync Status
77 
78```
79/pw:testrail status --project <id>
80```
81 
82Steps:
831. Fetch test cases from TestRail
842. Scan local Playwright tests for TestRail annotations
853. Report coverage:
86 ```
87 TestRail cases: 150
88 Playwright tests with TestRail IDs: 120
89 Unlinked TestRail cases: 30
90 Playwright tests without TestRail IDs: 15
91 ```
92 
93### 5. Update Test Cases in TestRail
94 
95```
96/pw:testrail update --case <id>
97```
98 
99Steps:
1001. Read the Playwright test for this case ID
1012. Extract steps and expected results from test code
1023. Call `testrail_update_case` MCP tool to update steps
103 
104## MCP Tools Used
105 
106| Tool | When |
107|---|---|
108| `testrail_get_projects` | List available projects |
109| `testrail_get_suites` | List suites in project |
110| `testrail_get_cases` | Read test cases |
111| `testrail_add_case` | Create new test case |
112| `testrail_update_case` | Update existing case |
113| `testrail_add_run` | Create test run |
114| `testrail_add_result` | Push individual result |
115| `testrail_get_results` | Read historical results |
116 
117## Test Annotation Format
118 
119All Playwright tests linked to TestRail include:
120 
121```typescript
122test('should login successfully', async ({ page }) => {
123 test.info().annotations.push({
124 type: 'testrail',
125 description: 'C12345',
126 });
127 // ... test code
128});
129```
130 
131This annotation is the bridge between Playwright and TestRail.
132 
133## Output
134 
135- Operation summary with counts
136- Any errors or unmatched cases
137- Link to TestRail run/results
138 

Discussion