{"id":20137075,"url":"https://github.com/ctrf-io/playwright-ctrf-json-reporter","last_synced_at":"2026-04-01T21:37:16.534Z","repository":{"id":222171697,"uuid":"729931365","full_name":"ctrf-io/playwright-ctrf-json-reporter","owner":"ctrf-io","description":"A Playwright JSON test results reporter that follows the CTRF schema","archived":false,"fork":false,"pushed_at":"2025-03-31T17:21:09.000Z","size":677,"stargazers_count":64,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T17:25:42.008Z","etag":null,"topics":["playwright","playwright-reporter","test-automation","test-reporting"],"latest_commit_sha":null,"homepage":"https://ctrf.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctrf-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-10T19:36:45.000Z","updated_at":"2025-03-28T09:32:35.000Z","dependencies_parsed_at":"2024-02-12T19:26:35.129Z","dependency_job_id":"839c8282-2d7a-4fa0-8be1-c8ffb519c65e","html_url":"https://github.com/ctrf-io/playwright-ctrf-json-reporter","commit_stats":null,"previous_names":["ctrf-io/playwright-ctrf-json-report","ctrf-io/playwright-ctrf-json-reporter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fplaywright-ctrf-json-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fplaywright-ctrf-json-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fplaywright-ctrf-json-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctrf-io%2Fplaywright-ctrf-json-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctrf-io","download_url":"https://codeload.github.com/ctrf-io/playwright-ctrf-json-reporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248080832,"owners_count":21044571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["playwright","playwright-reporter","test-automation","test-reporting"],"created_at":"2024-11-13T21:25:04.663Z","updated_at":"2026-04-01T21:37:16.526Z","avatar_url":"https://github.com/ctrf-io.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Reporters"],"sub_categories":[],"readme":"# Playwright JSON Test Results Report\n\n\u003e Save Playwright test results as a JSON file\n\nA Playwright JSON test reporter to create test reports that follow the CTRF standard.\n\n[Common Test Report Format](https://ctrf.io) ensures the generation of uniform JSON test reports, independent of programming languages or test framework in use.\n\n## CTRF Open Standard\n\nCTRF is a community-driven open standard for test reporting.\n\nBy standardizing test results, reports can be validated, merged, compared, and analyzed consistently across languages and frameworks.\n\n- **CTRF Specification**: https://github.com/ctrf-io/ctrf  \n  The official specification defining the format and semantics\n- **Discussions**: https://github.com/orgs/ctrf-io/discussions  \n  Community forum for questions, ideas, and support\n\n\u003e [!NOTE]  \n\u003e ⭐ Starring the **CTRF specification repository** (https://github.com/ctrf-io/ctrf)\n\u003e helps support the standard.\n\n## Features\n\n![Static Badge](https://img.shields.io/badge/official-red?label=ctrf\u0026labelColor=green)\n[![build](https://github.com/ctrf-io/playwright-ctrf-json-report/actions/workflows/main.yaml/badge.svg)](https://github.com/ctrf-io/playwright-ctrf-json-report/actions/workflows/main.yaml)\n![NPM Downloads](https://img.shields.io/npm/d18m/playwright-ctrf-json-reporter?logo=npm)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/playwright-ctrf-json-reporter?label=Size)\n![GitHub Repo stars](https://img.shields.io/github/stars/ctrf-io/playwright-ctrf-json-report)\n\n- Generate JSON test reports that are [CTRF](https://ctrf.io) compliant\n- Customizable output options, minimal or comprehensive reports\n- Straightforward integration with Playwright\n- Enhanced test insights with detailed test information, environment details, and more.\n\n```json\n{\n  \"results\": {\n    \"tool\": {\n      \"name\": \"playwright\"\n    },\n    \"summary\": {\n      \"tests\": 1,\n      \"passed\": 1,\n      \"failed\": 0,\n      \"pending\": 0,\n      \"skipped\": 0,\n      \"other\": 0,\n      \"start\": 1706828654274,\n      \"stop\": 1706828655782\n    },\n    \"tests\": [\n      {\n        \"name\": \"ctrf should generate the same report with any tool\",\n        \"status\": \"passed\",\n        \"duration\": 100\n      }\n    ],\n    \"environment\": {\n      \"appName\": \"MyApp\",\n      \"buildName\": \"MyBuild\",\n      \"buildNumber\": \"1\"\n    }\n  }\n}\n```\n\n## Installation\n\n```bash\nnpm install --save-dev playwright-ctrf-json-reporter\n```\n\nAdd the reporter to your playwright.config.ts file:\n\n```javascript\nreporter: [\n  ['list'], // You can combine multiple reporters\n  ['playwright-ctrf-json-reporter', {}]\n],\n```\n\nRun your tests:\n\n```bash\nnpx playwright test\n```\n\nYou'll find a JSON file named `ctrf-report.json` in the `ctrf` directory.\n\n## Reporter Options\n\nThe reporter supports several configuration options:\n\n```javascript\nreporter: [\n    ['playwright-ctrf-json-reporter', {\n        outputFile: 'custom-name.json', // Optional: Output file name. Defaults to 'ctrf-report.json'.\n        outputDir: 'custom-directory',  // Optional: Output directory path. Defaults to '.' (project root).\n        minimal: true,                  // Optional: Generate a minimal report. Defaults to 'false'. Overrides screenshot and testType when set to true\n        screenshot: false,              // Optional: Include screenshots in the report. Defaults to 'false'.\n        annotations: false,             // Optional: Include annotations in the report. Defaults to 'false'.\n        testType: 'e2e',                // Optional: Specify the test type (e.g., 'api', 'e2e'). Defaults to 'e2e'.\n        appName: 'MyApp',               // Optional: Specify the name of the application under test.\n        appVersion: '1.0.0',            // Optional: Specify the version of the application under test.\n        osPlatform: 'linux',            // Optional: Specify the OS platform.\n        osRelease: '18.04',             // Optional: Specify the OS release version.\n        osVersion: '5.4.0',             // Optional: Specify the OS version.\n        buildName: 'MyApp Build',       // Optional: Specify the build name.\n        buildNumber: '100',             // Optional: Specify the build number.\n        buildUrl: \"https://ctrf.io\",    // Optional: Specify the build url.\n        repositoryName: \"ctrf-json\",    // Optional: Specify the repository name.\n        repositoryUrl: \"https://gh.io\", // Optional: Specify the repository url.\n        branchName: \"main\",             // Optional: Specify the branch name.\n        commit: \"abc123\",               // Optional: Specify the commit id.\n        testEnvironment: \"staging\"      // Optional: Specify the test environment (e.g. staging, production).\n    }]\n  ],\n```\n\nA comprehensive report is generated by default, with the exception of screenshots, which you must explicitly set to true.\n\nTo disable stdio use Playwright built in `quiet` configuration option.\n\n## Merge reports\n\nWhen running tests in parallel, each test shard has its own test report. If you want to have a combined report showing all the test results from all the shards, you can merge them.\n\nThe [ctrf-cli](https://github.com/ctrf-io/ctrf-cli) package provides a method to merge multiple ctrf json files into a single file.\n\nAfter executing your tests, use the following command:\n\n```sh\nnpx ctrf merge \u003cdirectory\u003e\n```\n\nReplace directory with the path to the directory containing the CTRF reports you want to merge.\n\n## Test Object Properties\n\nThe test object in the report includes the following [CTRF properties](https://ctrf.io/docs/schema/test):\n\n| Name          | Type             | Required | Details                                                                             |\n| ------------- | ---------------- | -------- | ----------------------------------------------------------------------------------- |\n| `name`        | String           | Required | The name of the test.                                                               |\n| `status`      | String           | Required | The outcome of the test. One of: `passed`, `failed`, `skipped`, `pending`, `other`. |\n| `duration`    | Number           | Required | The time taken for the test execution, in milliseconds.                             |\n| `start`       | Number           | Optional | The start time of the test as a Unix epoch timestamp.                               |\n| `stop`        | Number           | Optional | The end time of the test as a Unix epoch timestamp.                                 |\n| `suite`       | String           | Optional | The suite or group to which the test belongs.                                       |\n| `message`     | String           | Optional | The failure message if the test failed.                                             |\n| `trace`       | String           | Optional | The stack trace captured if the test failed.                                        |\n| `snippet`     | String           | Optional | The code snippet that was executed during the test if the test failed.              |\n| `rawStatus`   | String           | Optional | The original playwright status of the test before mapping to CTRF status.           |\n| `tags`        | Array of Strings | Optional | The tags retrieved from the test name                                               |\n| `type`        | String           | Optional | The type of test (e.g., `api`, `e2e`).                                              |\n| `filepath`    | String           | Optional | The file path where the test is located in the project.                             |\n| `retries`     | Number           | Optional | The number of retries attempted for the test.                                       |\n| `flaky`       | Boolean          | Optional | Indicates whether the test result is flaky.                                         |\n| `browser`     | String           | Optional | The browser used for the test.                                                      |\n| `attachments` | Array of Objects | Optional | The attachments attached to the test.                                               |\n| `stdout`      | Array of Strings | Optional | The standard output of the test.                                                    |\n| `stderr`      | Array of Strings | Optional | The standard error of the test.                                                     |\n| `screenshot`  | String           | Optional | A base64 encoded screenshot taken during the test.                                  |\n| `steps`       | Array of Objects | Optional | Individual steps in the test, especially for BDD-style testing.                     |\n\n## Extra\n\nThe `extra` field lets you attach custom metadata to individual test results at runtime. This data is merged into the `extra` field of each test in the CTRF report.\n\nSee the [CTRF extra specification](https://www.ctrf.io/docs/specification/extra) for full details.\n\n### Usage\n\nImport `ctrf` from the reporter and call `ctrf.extra()` inside any test:\n\n```typescript\nimport { test, expect } from '@playwright/test'\nimport { ctrf } from 'playwright-ctrf-json-reporter'\n\ntest('checkout flow', async ({ page }) =\u003e {\n  ctrf.extra({ owner: 'checkout-team', priority: 'P1' })\n\n  // ... test logic ...\n})\n```\n\nYou can call it multiple times in a single test:\n\n```typescript\ntest('search results', async ({ page }) =\u003e {\n  ctrf.extra({ owner: 'search-team' })\n  ctrf.extra({ feature: 'search', environment: 'staging' })\n\n  // ... test logic ...\n\n  ctrf.extra({ customMetric: 'some-value' })\n})\n```\n\nThe resulting `extra` field in the CTRF report:\n\n```json\n{\n  \"name\": \"search results\",\n  \"status\": \"passed\",\n  \"duration\": 300,\n  \"extra\": {\n    \"owner\": \"search-team\",\n    \"feature\": \"search\",\n    \"environment\": \"staging\",\n    \"customMetric\": \"some-value\"\n  }\n}\n```\n\n### Merge behaviour\n\n| Data type  | Behaviour                           | Example                                                                                                        |\n| ---------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------- |\n| Primitives | Later call overwrites earlier       | `extra({ owner: 'a' })` then `extra({ owner: 'b' })` → `{ owner: 'b' }`                                        |\n| Objects    | Deep merged - nested keys preserved | `extra({ build: { id: '1' } })` then `extra({ build: { url: '...' } })` → `{ build: { id: '1', url: '...' } }` |\n| Arrays     | Concatenated across calls           | `extra({ tags: ['smoke'] })` then `extra({ tags: ['e2e'] })` → `{ tags: ['smoke', 'e2e'] }`                    |\n\n## Advanced usage\n\nSome features require additional setup or usage considerations.\n\n### Annotations\n\nBy setting `annotations: true` you can include annotations in the test extra property.\n\n### Screenshots\n\nYou can include base-64 screenshots in your test report, you'll need to capture and attach screenshots in your Playwright tests:\n\n```javascript\nimport { test, expect } from '@playwright/test'\n\ntest('basic test', async ({ page }, testInfo) =\u003e {\n  await page.goto('https://playwright.dev')\n  const screenshot = await page.screenshot({ quality: 50, type: 'jpeg' })\n  await testInfo.attach('screenshot', {\n    body: screenshot,\n    contentType: 'image/jpeg',\n  })\n})\n```\n\n#### Supported Formats\n\nBoth JPEG and PNG formats are supported, only the last screenshot attached from each test will be included in the report.\n\n#### Size Considerations\n\nBase64-encoded image data can greatly increase the size of your report, it's recommended to use screenshots with a lower quality setting (less than 50%) to reduce file size, particularly if you are generating JPEG images.\n\n### Browser\n\nYou can include browser information in your test report. You will need to extend Playwright's test object to capture and attach browser metadata for each test:\n\n```javascript\n// tests/helpers.ts\nimport { test as _test, expect } from '@playwright/test';\nimport os from 'os';\n\nexport const test = _test.extend\u003c{ _autoAttachMetadata: void }\u003e({\n    _autoAttachMetadata: [async ({ browser, browserName }, use, testInfo) =\u003e {\n        // BEFORE: Generate an attachment for the test with the required info\n        await testInfo.attach('metadata.json', {\n            body: JSON.stringify({\n                name: browserName,\n                version: browser.version(),\n            })\n        })\n\n        // ---------------------------------------------------------\n        await use(/** our test doesn't need this fixture direcly */);\n        // ---------------------------------------------------------\n\n        // AFTER: There's nothing to cleanup in this fixutre\n    }, { auto: true }],\n})\n\nexport { expect };\n```\n\nReplace the standard Playwright test import with the custom test fixture in your test files:\n\n```javascript\n// tests/my-test.spec.ts\nimport { test, expect } from './helpers' // Adjust the path as necessary\n\ntest('example test', async ({ page }) =\u003e {\n  // ... your test logic ...\n})\n```\n\nThe browser metadata file must be called metadata.json and contain properties name and version in the body.\n\n## What is CTRF?\n\nCTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.\n\n**Consistency Across Tools:** Different testing tools and frameworks often produce reports in varied formats. CTRF ensures a uniform structure, making it easier to understand and compare reports, regardless of the testing tool used.\n\n**Language and Framework Agnostic:** It provides a universal reporting schema that works seamlessly with any programming language and testing framework.\n\n**Facilitates Better Analysis:** With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrf-io%2Fplaywright-ctrf-json-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctrf-io%2Fplaywright-ctrf-json-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctrf-io%2Fplaywright-ctrf-json-reporter/lists"}