{"id":25044974,"url":"https://github.com/sectorlabs/wdio-junit-reporter","last_synced_at":"2025-03-31T00:14:49.961Z","repository":{"id":183451945,"uuid":"670160431","full_name":"SectorLabs/wdio-junit-reporter","owner":"SectorLabs","description":"Wdio custom junit reporter","archived":false,"fork":false,"pushed_at":"2023-10-11T08:46:31.000Z","size":442,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T16:01:49.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/SectorLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-24T12:28:49.000Z","updated_at":"2023-07-24T12:52:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5e5a25e-2b5b-4c11-9d29-6b1bbf04c2f9","html_url":"https://github.com/SectorLabs/wdio-junit-reporter","commit_stats":null,"previous_names":["sectorlabs/wdio-junit-reporter"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SectorLabs%2Fwdio-junit-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SectorLabs%2Fwdio-junit-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SectorLabs%2Fwdio-junit-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SectorLabs%2Fwdio-junit-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SectorLabs","download_url":"https://codeload.github.com/SectorLabs/wdio-junit-reporter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246395591,"owners_count":20770243,"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":[],"created_at":"2025-02-06T05:20:07.287Z","updated_at":"2025-03-31T00:14:49.938Z","avatar_url":"https://github.com/SectorLabs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"WebdriverIO XML Reporter\n========================\n\n\u003e A WebdriverIO reporter that creates [Jenkins](http://jenkins-ci.org/) compatible XML based JUnit reports\n\n## Installation\n\nThe easiest way is to keep `@wdio/junit-reporter` as a devDependency in your `package.json`, via:\n\n```sh\nnpm install @wdio/junit-reporter --save-dev\n```\n\nInstructions on how to install `WebdriverIO` can be found [here](https://webdriver.io/docs/gettingstarted).\n\n## Output\n\nThis reporter will output a report for each runner, so in turn you will receive an xml report for each spec file. Below\nare examples of XML output given different scenarios in the spec file.\n\n### Single describe block\n```javascript\ndescribe('a test suite', () =\u003e {\n    it('a test case', function () {\n      // do something\n      // assert something\n    });\n});\n```\nbecomes\n```xml\n\u003ctestsuites\u003e\n    \u003ctestsuite name=\"a test suite\" timestamp=\"2019-04-18T13:45:21\" time=\"11.735\" tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\"\u003e\n        \u003cproperties\u003e\n          \u003cproperty name=\"specId\" value=\"0\"/\u003e\n          \u003cproperty name=\"suiteName\" value=\"a test suite\"/\u003e\n          \u003cproperty name=\"capabilities\" value=\"chrome\"/\u003e\n          \u003cproperty name=\"file\" value=\".\\test\\specs\\asuite.spec.js\"/\u003e\n        \u003c/properties\u003e\n        \u003ctestcase classname=\"chrome.a_test_case\" name=\"a_test_suite_a_test_case\" time=\"11.706\"/\u003e\n    \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n### Nested describe block\n```javascript\ndescribe('a test suite', () =\u003e {\n    describe('a nested test suite', function() {\n        it('a test case', function () {\n          // do something\n          // assert something\n        });\n    });\n});\n```\nbecomes\n```xml\n\u003ctestsuites\u003e\n    \u003ctestsuite name=\"a test suite\" timestamp=\"2019-04-18T13:45:21\" time=\"11.735\" tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\"\u003e\n    \u003cproperties\u003e\n      \u003cproperty name=\"specId\" value=\"0\"/\u003e\n      \u003cproperty name=\"suiteName\" value=\"a test suite\"/\u003e\n      \u003cproperty name=\"capabilities\" value=\"chrome\"/\u003e\n      \u003cproperty name=\"file\" value=\".\\test\\specs\\asuite.spec.js\"/\u003e\n    \u003c/properties\u003e\n  \u003c/testsuite\u003e\n  \u003ctestsuite name=\"a nested test suite\" timestamp=\"2019-04-18T13:45:21\" time=\"11.735\" tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\"\u003e\n    \u003cproperties\u003e\n      \u003cproperty name=\"specId\" value=\"0\"/\u003e\n      \u003cproperty name=\"suiteName\" value=\"a nested test suite\"/\u003e\n      \u003cproperty name=\"capabilities\" value=\"chrome\"/\u003e\n      \u003cproperty name=\"file\" value=\".\\test\\specs\\asuite.spec.js\"/\u003e\n    \u003c/properties\u003e\n    \u003ctestcase classname=\"chrome.a_test_case\" name=\"a nested test suite a test case\" time=\"11.706\"/\u003e\n  \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n### Multiple describe block\n```javascript\ndescribe('a test suite', () =\u003e {\n    it('a test case', function () {\n      // do something\n      // assert something\n    });\n});\ndescribe('a second test suite', () =\u003e {\n    it('a second test case', function () {\n      // do something\n      // assert something\n    });\n});\n```\nbecomes\n```xml\n\u003ctestsuites\u003e\n    \u003ctestsuite name=\"a test suite\" timestamp=\"2019-04-18T13:45:21\" time=\"11.735\" tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\"\u003e\n    \u003cproperties\u003e\n      \u003cproperty name=\"specId\" value=\"0\"/\u003e\n      \u003cproperty name=\"suiteName\" value=\"a test suite\"/\u003e\n      \u003cproperty name=\"capabilities\" value=\"chrome\"/\u003e\n      \u003cproperty name=\"file\" value=\".\\test\\specs\\asuite.spec.js\"/\u003e\n      \u003ctestcase classname=\"chrome.a_test_case\" name=\"a nested test suite a test case\" time=\"11.706\"/\u003e\n    \u003c/properties\u003e\n  \u003c/testsuite\u003e\n  \u003ctestsuite name=\"a second test suite\" timestamp=\"2019-04-18T13:45:21\" time=\"11.735\" tests=\"0\" failures=\"0\" errors=\"0\" skipped=\"0\"\u003e\n    \u003cproperties\u003e\n      \u003cproperty name=\"specId\" value=\"0\"/\u003e\n      \u003cproperty name=\"suiteName\" value=\"a second test suite\"/\u003e\n      \u003cproperty name=\"capabilities\" value=\"chrome\"/\u003e\n      \u003cproperty name=\"file\" value=\".\\test\\specs\\asuite.spec.js\"/\u003e\n    \u003c/properties\u003e\n    \u003ctestcase classname=\"chrome.a_second_test_case\" name=\"a_second_test_suite_a_second_test_case\" time=\"11.706\"/\u003e\n  \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n### Failures and Errors\nAll test case failures are mapped as JUnit test case errors. A failed test case due to assertion failure or error will look like:\n\n```xml\n\u003ctestcase classname=\"chrome.a_test_case\" name=\"a_test_suite_a_test_case\" time=\"0.372\"\u003e\n  \u003cerror message=\"Error: some error\"/\u003e\n    \u003csystem-err\u003e\n        \u003c![CDATA[\nError: some assertion failure\n    at UserContext.\u003canonymous\u003e (C:\\repo\\webdriver-example\\test\\specs/a_test_suite.spec.js:22:17)\n]]\u003e\n  \u003c/system-err\u003e\n\u003c/testcase\u003e\n```\n\n## Configuration\n\nFollowing code shows the default wdio test runner configuration. Just add `'junit'` as reporter\nto the array. To get some output during the test you can run the [WDIO Dot Reporter](https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-dot-reporter) and the WDIO JUnit Reporter at the same time:\n\n```js\n// wdio.conf.js\nmodule.exports = {\n    // ...\n    reporters: [\n        'dot',\n        ['junit', {\n            outputDir: './',\n            outputFileFormat: function(options) { // optional\n                return `results-${options.cid}.${options.capabilities}.xml`\n            }\n        }]\n    ],\n    // ...\n};\n```\n\nThe following options are supported:\n\n### outputDir\nDefine a directory where your xml files should get stored.\n\nType: `String`\u003cbr /\u003e\nRequired\n\n### outputFileFormat\nDefine the xml files created after the test execution.\n\nType: `Object`\u003cbr /\u003e\nDefault: ``function (opts) { return `wdio-${this.cid}-${name}-reporter.log` }``\n\n```\noutputFileFormat: function (options) {\n    return 'mycustomfilename.xml';\n}\n```\n\n\u003e Note: `options.capabilities` is your capabilities object for that runner, so specifying `${options.capabilities}` in your string will return [Object object]. You must specify which properties of capabilities you want in your filename.\n\n### suiteNameFormat\n\nGives the ability to provide custom regex for formatting test suite name (e.g. in output xml ).\n\nType: `Regex`,\u003cbr /\u003e\nDefault: `/[^a-zA-Z0-9@]+/`\n\n```js\n// wdio.conf.js\nmodule.exports = {\n    // ...\n    reporters: [\n        'dot',\n        ['junit', {\n            outputDir: './',\n            suiteNameFormat: /[^a-zA-Z0-9@]+/\n            outputFileFormat: function(options) { // optional\n                return `results-${options.cid}.${options.capabilities}.xml`\n            }\n        }]\n    ],\n    // ...\n};\n```\n\n### addFileAttribute\n\nAdds a file attribute to each testcase. This config is primarily for CircleCI. This setting provides richer details but may break on other CI platforms.\n\nType: `Boolean`,\u003cbr /\u003e\nDefault: `false`\n\n\n### packageName\n\nYou can break out packages by an additional level by setting `'packageName'`. For example, if you wanted to iterate over a test suite with different environment variable set:\n\nType: `String`\u003cbr /\u003e\nExample:\n\n```js\n// wdio.conf.js\nmodule.exports = {\n    // ...\n    reporters: [\n        'dot',\n        ['junit', {\n            outputDir: './',\n            packageName: process.env.USER_ROLE // chrome.41 - administrator\n        }]\n    ]\n    // ...\n};\n```\n\n### errorOptions\n\nAllows to set various combinations of error notifications inside xml.\u003cbr /\u003e\nGiven a Jasmine test like `expect(true).toBe(false, 'my custom message')` you will get this test error:\n\n```\n{\n    matcherName: 'toBe',\n    message: 'Expected true to be false, \\'my custom message\\'.',\n    stack: 'Error: Expected true to be false, \\'my custom message\\'.\\n    at UserContext.it (/home/mcelotti/Workspace/WebstormProjects/forcebeatwio/test/marco/prova1.spec.js:3:22)',\n    passed: false,\n    expected: [ false, 'my custom message' ],\n    actual: true\n}\n```\n\nTherefore you can choose *which* key will be used *where*, see the example below.\n\nType: `Object`,\u003cbr /\u003e\nDefault: `errorOptions: { error: \"message\" }`\u003cbr /\u003e\nExample:\n\n```js\n// wdio.conf.js\nmodule.exports = {\n    // ...\n    reporters: [\n        'dot',\n        ['junit', {\n            outputDir: './',\n            errorOptions: {\n                error: 'message',\n                failure: 'message',\n                stacktrace: 'stack'\n            }\n        }]\n    ],\n    // ...\n};\n```\n\n## Jenkins Setup\n\nLast but not least you need to tell your CI job (e.g. Jenkins) where it can find the xml file. To do that, add a post-build action to your job that gets executed after the test has run and point Jenkins (or your desired CI system) to your XML test results:\n\n![Point Jenkins to XML files](https://webdriver.io/img/jenkins-postjob.png \"Point Jenkins to XML files\")\n\nIf there is no such post-build step in your CI system there is probably a plugin for that somewhere on the internet.\n\n----\n\nFor more information on WebdriverIO see the [homepage](https://webdriver.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsectorlabs%2Fwdio-junit-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsectorlabs%2Fwdio-junit-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsectorlabs%2Fwdio-junit-reporter/lists"}