{"id":15046989,"url":"https://github.com/xray-app/playwright-junit-reporter","last_synced_at":"2026-01-26T17:12:42.384Z","repository":{"id":157297978,"uuid":"633350164","full_name":"Xray-App/playwright-junit-reporter","owner":"Xray-App","description":"Playwright JUnit Enhanced XML reporter","archived":false,"fork":false,"pushed_at":"2025-07-10T13:32:59.000Z","size":321,"stargazers_count":12,"open_issues_count":8,"forks_count":7,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-08-17T07:52:46.596Z","etag":null,"topics":["junit","playwright","testing","xray"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xray-App.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-27T10:02:44.000Z","updated_at":"2025-08-05T21:44:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8e19922-2913-4cc2-a426-bbc04e1aeb09","html_url":"https://github.com/Xray-App/playwright-junit-reporter","commit_stats":{"total_commits":23,"total_committers":4,"mean_commits":5.75,"dds":0.5652173913043479,"last_synced_commit":"cd1757fb466afa5b1761b0bc8ea885aec0f7f305"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/Xray-App/playwright-junit-reporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xray-App%2Fplaywright-junit-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xray-App%2Fplaywright-junit-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xray-App%2Fplaywright-junit-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xray-App%2Fplaywright-junit-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xray-App","download_url":"https://codeload.github.com/Xray-App/playwright-junit-reporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xray-App%2Fplaywright-junit-reporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273656518,"owners_count":25145001,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["junit","playwright","testing","xray"],"created_at":"2024-09-24T20:53:50.803Z","updated_at":"2026-01-26T17:12:42.353Z","avatar_url":"https://github.com/Xray-App.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enhanced Playwright JUnit XML reporter compatible with Xray\n\n[![npm version](https://img.shields.io/npm/v/@xray-app/playwright-junit-reporter.svg?style=flat-square)](https://www.npmjs.com/package/@xray-app/playwright-junit-reporter)\n[![build workflow](https://github.com/Xray-App/playwright-junit-reporter/actions/workflows/build.yml/badge.svg)](https://github.com/Xray-App/playwright-junit-reporter/actions/workflows/build.yml)\n[![license](https://img.shields.io/badge/License-Apache%202-green.svg)](https://opensource.org/license/apache-2-0/)\n[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/Xray-App/community)\n[![npm downloads](https://img.shields.io/npm/dm/@xray-app/playwright-junit-reporter.svg?style=flat-square)](http://npm-stat.com/charts.html?package=@xray-app/playwright-junit-reporter)\n\nThis enhanced JUnit reporter produces a JUnit-style XML report, supported by [Xray](https://www.getxray.app).\nUntil Playwright v1.33, Playwright's built-in `junit` reporter provided support for Xray enhancements; as of v1.34 that support is removed from the Playwright project itself and is supported through this project, having the same set of features.\n\n## Installation\n\nRun the following commands:\n\n### npm\n\n`npm install @xray-app/playwright-junit-reporter --save-dev`\n\n### yarn\n\n`yarn add @xray-app/playwright-junit-reporter --dev`\n\n## Usage\n\nMost likely you want to write the report to an xml file. When running with `--reporter=@xray-app/playwright-junit-reporter`, use `PLAYWRIGHT_JUNIT_OUTPUT_NAME` environment variable:\n\n```bash tab=bash-bash\nPLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=@xray-app/playwright-junit-reporter\n```\n\n```batch tab=bash-batch\nset PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml\nnpx playwright test --reporter=@xray-app/playwright-junit-reporter\n```\n\n```powershell tab=bash-powershell\n$env:PLAYWRIGHT_JUNIT_OUTPUT_NAME=\"results.xml\"\nnpx playwright test --reporter=@xray-app/playwright-junit-reporter\n```\n\nIn configuration file, pass options directly:\n\n```js\nimport { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n  reporter: [['@xray-app/playwright-junit-reporter', { outputFile: 'results.xml' }]],\n});\n```\n\nThe JUnit reporter provides support for embedding additional information on the `testcase` elements using inner `properties`. This is based on an [evolved JUnit XML format](https://docs.getxray.app/display/XRAYCLOUD/Taking+advantage+of+JUnit+XML+reports) from Xray Test Management, but can also be used by other tools if they support this way of embedding additional information for test results; please check it first.\n\nIn configuration file, a set of options can be used to configure this behavior. A full example, in this case for Xray, follows ahead.\n\n```js\nimport { defineConfig } from '@playwright/test';\n\n// JUnit reporter config for Xray\nconst xrayOptions = {\n  // Whether to add \u003cproperties\u003e with all annotations (except the ones that start with \"tr:\"); default is false.\n  embedAnnotationsAsProperties: true,\n\n  // Whether to add test run related annotations (the ones whose type/name is \"tr:xxxx\"), that map to custom fields on the Test Runs, as \u003citems\u003e within a special `\u003cproperty name=\"testrun_customfields\"\u003e`; default is false.\n  embedTestrunAnnotationsAsItemProperties: true,\n\n\n  // Whether to ignore tests that do not contain an annotation of type 'test_key'; default is false\n  // This is useful, if you have tests without a test_key property in your testsuite, \n  // but still want to import the report into Xray without those tests.\n  ignoreTestCasesWithoutTestKey: false,\n\n  // By default, annotation is reported as \u003cproperty name='' value=''\u003e.\n  // These annotations are reported as \u003cproperty name=''\u003evalue\u003c/property\u003e. This only applies if using the `embedAnnotationsAsProperties` setting; it's not applicable to the test run related annotations that are handled by the `embedAnnotationsAsItemProperties` setting.\n  textContentAnnotations: ['test_description', 'testrun_comment'],\n\n  // This will create a \"testrun_evidence\" property that contains all attachments. Each attachment is added as an inner \u003citem\u003e element.\n  // Disables [[ATTACHMENT|path]] in the \u003csystem-out\u003e.\n  embedAttachmentsAsProperty: 'testrun_evidence',\n\n  // Where to put the report.\n  outputFile: './xray-report.xml'\n};\n\nexport default defineConfig({\n  reporter: [['@xray-app/playwright-junit-reporter', xrayOptions]]\n});\n```\n\nIn the previous configuration sample, all annotations will be added as `\u003cproperty\u003e` elements on the JUnit XML report. The annotation type is mapped to the `name` attribute of the `\u003cproperty\u003e`, and the annotation description will be added as a `value` attribute. In this case, the exception will be the annotation type `testrun_evidence` whose description will be added as inner content on the respective `\u003cproperty\u003e`.\nAnnotations can be used to, for example, link a Playwright test with an existing Test in Xray or to link a test with an existing story/requirement in Jira (i.e., \"cover\" it).\n\n```js\n// example.spec.ts/js\nimport { test } from '@playwright/test';\n\ntest('using specific annotations for passing test metadata to Xray', async ({}, testInfo) =\u003e {\n  // Xray will process only properties from the Junit XML report that it is aware of; other properties are discarded\n  testInfo.annotations.push({ type: 'test_id', description: '1234' });\n  testInfo.annotations.push({ type: 'test_key', description: 'CALC-2' });\n  testInfo.annotations.push({ type: 'test_summary', description: 'sample summary' });\n  testInfo.annotations.push({ type: 'requirements', description: 'CALC-5,CALC-6' });\n  testInfo.annotations.push({ type: 'test_description', description: 'sample description' });\n\n  // add some information to custom fields on the Test Run; these custom fields need to be created before in Xray settings, eventually on the project settings\n  // setting some text on a TR custom field of type \"text - single line\"\n  testInfo.annotations.push({ type: 'tr:basic_cf', description: 'dummycontent' });\n  // setting some text on a TR custom field of type \"multiselect\", with checked options delimited using ;\n  testInfo.annotations.push({ type: 'tr:multiselect_cf', description: 'a;b;c' });\n  // setting some text on a TR custom field of type \"text\"\n  const multilineString = \"Hello world\\nThis is a multiline string\";\n  testInfo.annotations.push({ type: 'tr:multiline_cf', description: multilineString });\n\n});\n```\n\nPlease note that the semantics of these properties will depend on the tool that will process this evolved report format; there are no standard property names/annotations.\n\nIf the configuration option `embedAttachmentsAsProperty` is defined, then a `property` with its name is created. Attachments, including their contents, will be embedded on the JUnit XML report inside `\u003citem\u003e` elements under this `property`. Attachments are obtained from the `TestInfo` object, using either a path or a body, and are added as base64 encoded content.\nEmbedding attachments can be used to attach screenshots or any other relevant evidence; nevertheless, use it wisely as it affects the report size.\n\nThe following configuration sample enables embedding attachments by using the `testrun_evidence` element on the JUnit XML report:\n\n```js\nimport { defineConfig } from '@playwright/test';\n\nexport default defineConfig({\n  reporter: [['@xray-app/playwright-junit-reporter', { embedAttachmentsAsProperty: 'testrun_evidence', outputFile: 'results.xml' }]],\n});\n```\n\nThe following test adds attachments:\n\n```js\n// example.spec.ts/js\nimport { test } from '@playwright/test';\n\ntest('embed attachments, including its content, on the JUnit report', async ({}, testInfo) =\u003e {\n  const file = testInfo.outputPath('evidence1.txt');\n  require('fs').writeFileSync(file, 'hello', 'utf8');\n  await testInfo.attach('evidence1.txt', { path: file, contentType: 'text/plain' });\n  await testInfo.attach('evidence2.txt', { body: Buffer.from('world'), contentType: 'text/plain' });\n});\n```\n\n## Summary of supported attributes of the evolved JUnit XML format\n\n\n| Attributes | Usage Example |\n|---|---|\n| test_id  | testInfo.annotations.push({ type: 'test_id', description: '1234' }); |\n| test_key  | testInfo.annotations.push({ type: 'test_id', description: 'CALC-124' }); |\n| requirements  | testInfo.annotations.push({ type: 'requirements', description: 'CALC-2' }); |\n| testrun_comment  | testInfo.annotations.push({ type: 'testrun_comment', description: 'some comment, even\\nmultiline' }); |\n| test_summary  | testInfo.annotations.push({ type: 'test_summary', description: 'valid login scenario' }); |\n| test_description  | testInfo.annotations.push({ type: 'test_description', description: 'tests the valid login scenario\\nwhere user enters valid credentials and checks the redirect page' }); |\n| tr:xxx | testInfo.annotations.push({ type: 'tr:some_testrun_customfield', description: 'some extra info' }); |\n| _attachments_ |  testInfo.attach('evidence2.txt', { body: Buffer.from('world'), contentType: 'text/plain' }); |\n| tags (i.e., labels) |  testInfo.annotations.push({ type: 'tags', description: 'label1,label2' }); |\n\n\n## TO DOs\n\n- implement code coverage\n- integrate with @xray-app/xray-automation-js to upload results\n\n## Contact\n\nYou may find me on [Twitter](https://x.com/darktelecom).\nAny questions related with this code, please raise issues in this GitHub project. Feel free to contribute and submit PR's.\nFor Xray specific questions, please contact [Xray's support team](https://jira.getxray.app/servicedesk/customer/portal/2).\n\n## References\n\n- [How Xray processes JUnit XML reports](https://docs.getxray.app/display/XRAYCLOUD/Taking+advantage+of+JUnit+XML+reports)\n\n## LICENSE\n\nBased on code from [Playwright](https://github.com/microsoft/playwright/) project.\n\n[Apache License v2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxray-app%2Fplaywright-junit-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxray-app%2Fplaywright-junit-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxray-app%2Fplaywright-junit-reporter/lists"}