Configuration Options
These options are passed in the reporter tuple in your playwright.config.ts:
reporter: [
['@testplanit/playwright-reporter', { /* options */ }],
],
Required
| Option | Type | Description |
|---|---|---|
domain | string | Base URL of your TestPlanIt instance |
apiToken | string | API token for authentication (starts with tpi_) |
projectId | number | Project ID where results will be reported (find this on the Project Overview page) |
Optional
| Option | Type | Default | Description |
|---|---|---|---|
testRunId | number | string | - | Existing test run to add results to (ID or name). Defaults to the TESTPLANIT_RUN_ID environment variable. If set, runName is ignored and the reporter never completes the run |
runName | string | '{suite} - {date} {time}' | Name for new test runs (ignored if testRunId is set). Supports placeholders |
testRunType | string | 'JUNIT' | Test framework type stored on the run |
configId | number | string | - | Configuration for the test run (ID or name) |
milestoneId | number | string | - | Milestone for the test run (ID or name) |
stateId | number | string | - | Workflow state for the test run (ID or name) |
caseIdAnnotation | string | 'testplanit' | Playwright annotation type whose description holds the case ID(s) — the recommended way to link without renaming tests. Set to '' to disable. See Linking Test Cases |
caseIdPattern | RegExp | string | /\[(\d+)\]/g | Regex pattern for extracting case IDs from test titles and tags (must include a capturing group) |
autoCreateTestCases | boolean | false | Auto-create test cases if they don't exist |
createFolderHierarchy | boolean | false | Create folder hierarchy based on test.describe structure (requires autoCreateTestCases and parentFolderId) |
captureSteps | boolean | true | Capture test.step() calls as authored steps on auto-created cases (nested steps flattened in order, prefixed by depth). Requires autoCreateTestCases; applies only to newly created cases. See Capturing Steps |
overwriteSteps | boolean | false | Overwrite an existing case's steps with the captured test.step() calls every run (linked and auto-matched cases), keeping the case in sync as the script changes. Destructive — discards manual step edits; a test with no test.step() calls never clears existing steps. See Keeping steps in sync |
captureTags | boolean | true | Copy the test's Playwright tags onto auto-created cases (@smoke becomes a smoke tag; missing tags are created). A tag that matches caseIdPattern is not copied. Requires autoCreateTestCases; applies only to newly created cases. Requires TestPlanIt 1.0.0 or later |
overwriteTags | boolean | false | Make an existing case's tags match the test's Playwright tags every run (linked and auto-matched cases). Destructive: tags added to the case by hand are removed, and a test with no tags clears the case's tags. Requires TestPlanIt 1.0.0 or later |
parentFolderId | number | string | - | Folder for auto-created test cases (ID or name) |
templateId | number | string | - | Template for auto-created test cases (ID or name) |
tagIds | (number | string)[] | - | Tags to apply to the test run (IDs or names). Tags that don't exist are created automatically |
uploadAttachments | boolean | true | Upload Playwright attachments (screenshots, videos, traces) to the result — see Attachment Uploads |
attachmentTypes | string[] | all | Restrict which attachments upload, by attachment name or content-type prefix (e.g. ['image/']) |
includeStackTrace | boolean | true | Include stack traces for failures |
excludeSkipped | boolean | false | Don't report skipped tests — they won't appear on the run or count toward its totals |
expectedFailureStatus | number | string | failed status | Status (ID or name) recorded for a test.fail() test that fails as expected. See Expected Failures |
completeRunOnFinish | boolean | true | Mark run as complete when tests finish. Always off for a run given by testRunId or TESTPLANIT_RUN_ID |
timeout | number | 30000 | API request timeout in ms |
maxRetries | number | 3 | Retry attempts for failed requests |
verbose | boolean | false | Enable debug logging |
Options like configId, milestoneId, stateId, parentFolderId, and templateId accept either a numeric ID or a string name. When a string is provided, the resource is looked up by exact name match.
Run Name Placeholders
Customize your test run names with these placeholders:
| Placeholder | Description | Example |
|---|---|---|
{suite} | Root describe title of the first reported test | Login Tests |
{spec} | Spec file name (without extension) of the first reported test | login |
{date} | Current date in ISO format | 2024-01-15 |
{time} | Current time | 14:30:00 |
{browser} | Playwright project name | chromium |
{platform} | Platform/OS name | darwin, linux, win32 |
The default run name is '{suite} - {date} {time}'.
// playwright.config.ts
export default defineConfig({
reporter: [
['@testplanit/playwright-reporter', {
domain: 'https://testplanit.example.com',
apiToken: process.env.TESTPLANIT_API_TOKEN,
projectId: 1,
// Default: '{suite} - {date} {time}'
// Custom example:
runName: 'E2E Tests - {browser} - {date} {time}',
}],
],
});
Appending to Existing Test Runs
Add results to an existing test run instead of creating a new one:
// playwright.config.ts
export default defineConfig({
reporter: [
['@testplanit/playwright-reporter', {
domain: 'https://testplanit.example.com',
apiToken: process.env.TESTPLANIT_API_TOKEN,
projectId: 1,
testRunId: 456, // Add results to this existing run (ID or name)
}],
],
});
The reporter leaves an existing run open. Complete it from the pipeline once every job has reported (npx @testplanit/cli run complete).
This is useful for:
- Aggregating results from multiple CI jobs
- Running tests in parallel across machines
- Re-running failed tests without creating new runs
Associating with Configurations and Milestones
Track test results against specific configurations (browser/OS combinations) and milestones:
// playwright.config.ts
export default defineConfig({
reporter: [
['@testplanit/playwright-reporter', {
domain: 'https://testplanit.example.com',
apiToken: process.env.TESTPLANIT_API_TOKEN,
projectId: 1,
configId: 5, // e.g., "Chromium / macOS"
milestoneId: 10, // e.g., "Sprint 15"
stateId: 2, // e.g., "In Progress" workflow state
tagIds: ['regression', 'automated'],
}],
],
});
Result Statuses
The reporter records each result under one of the project's statuses. It only uses statuses that are enabled, assigned to the project, and have the Automation scope.
| Result | Status used |
|---|---|
| Passed | A status whose system name, name, or alias is passed, pass, or success. Otherwise the first status with Success turned on |
| Failed | A status whose system name, name, or alias is failed, fail, failure, or error. Otherwise the first status with Failure turned on |
| Skipped | A status whose system name, name, or alias is skipped, skip, or ignored. Otherwise the first status with Completed turned on and both Success and Failure turned off |
"First" follows the order of the statuses on the Statuses administration page. To send results to a particular status, add the matching word to its Aliases. An alias that only contains one of these words also matches when no status matches it exactly.
If no status fits, the reporter logs a warning and records the result without a status. TestPlanIt then counts it as passed, failed, or skipped from the result itself.
Expected Failures (test.fail())
Playwright treats a test marked with test.fail() as passing when it fails and as failing when it passes. The reporter records each attempt as follows:
Test marked test.fail() | Playwright | Recorded in TestPlanIt |
|---|---|---|
| Fails as expected | Passes the run | The failed status, or the status set by expectedFailureStatus |
| Passes | Fails the run | Failed, with the message Expected to fail, but passed. |
| Times out | Fails the run | Failed |
Set expectedFailureStatus to record expected failures under another status of the project, by name or ID:
// playwright.config.ts
export default defineConfig({
reporter: [
['@testplanit/playwright-reporter', {
domain: 'https://testplanit.example.com',
apiToken: process.env.TESTPLANIT_API_TOKEN,
projectId: 1,
expectedFailureStatus: 'Blocked', // by name
// expectedFailureStatus: 12, // …or by ID
}],
],
});
A name is matched against the name or system name of the project's statuses, ignoring case. The status must be enabled, assigned to the project, and have the Automation scope. The result counts as passed, failed, or neither according to that status's own settings.
If no status matches, the reporter logs a warning and records expected failures as failed.