Bidirectional sync between Playwright tests and TestRail test management.
Environment variables must be set:
TESTRAIL_URL — e.g., https://your-instance.testrail.io
TESTRAIL_USER — your emailTESTRAIL_API_KEY — API key from TestRailIf not set, inform the user how to configure them and stop.
/pw:testrail import --project <id> --suite <id>
Steps:
testrail_get_cases MCP tool to fetch test casestest.info().annotations.push({ type: 'testrail', description: 'C12345' })
/pw:testrail push --run <id>
Steps:
npx playwright test --reporter=json > test-results.json
testrail_add_result MCP tool for each test:
/pw:testrail run --project <id> --name "Sprint 42 Regression"
Steps:
testrail_add_run MCP tool/pw:testrail status --project <id>
Steps:
TestRail cases: 150
Playwright tests with TestRail IDs: 120
Unlinked TestRail cases: 30
Playwright tests without TestRail IDs: 15
/pw:testrail update --case <id>
Steps:
testrail_update_case MCP tool to update steps| 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 |
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.