{"name":"jest-junit","version":"17.0.0","description":"A jest reporter that generates junit xml files","main":"index.js","repository":{"type":"git","url":"git+https://github.com/jest-community/jest-junit.git"},"author":{"name":"Jason Palmer"},"license":"Apache-2.0","engines":{"node":">=20.0.0"},"scripts":{"test":"jest"},"dependencies":{"mkdirp":"^1.0.4","strip-ansi":"^6.0.1","uuid":"^14.0.0","xml":"^1.0.1"},"devDependencies":{"babel-jest":"^30.2.0","jest":"^30.2.0","libxml2-wasm":"^0.4.1","slash":"^3.0.0"},"_id":"jest-junit@17.0.0","gitHead":"20d8f149fcf7e03fd1a541e1d8d29ecf0a47fab6","bugs":{"url":"https://github.com/jest-community/jest-junit/issues"},"homepage":"https://github.com/jest-community/jest-junit#readme","_nodeVersion":"23.3.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-RYWCkq4j59gUXj5DsgbIE7xFBZzu1gtibPhyjSjMmGaOTLnqlXhg7x9zuGCwgbCuMAyoyvk0Mi8wSrRR5uOeLA==","shasum":"df70832d780de9577ba133688da94487f5bbc105","tarball":"http://registry-npm.ywwl.com/jest-junit/download/jest-junit-17.0.0.tgz","fileCount":10,"unpackedSize":42092,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDudQgTk2e8eSc2eqC69EaDR3Fy2V7Zs6iYJ/jnyBOS/AIhAMgwS7nEFO4p9BKT0K0azZUyzFRnikSUViPvMbpAGLsY"}],"size":12736,"noattachment":false,"key":"/jest-junit/-/jest-junit-17.0.0.tgz"},"_npmUser":{"name":"jsonp","email":"jason@jason-palmer.com"},"directories":{},"maintainers":[{"name":"jsonp","email":"jason@jason-palmer.com"},{"name":"rickhanlonii","email":"rickhanlonii@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jest-junit_17.0.0_1777038036601_0.4716834174980138"},"_hasShrinkwrap":false,"readme":"[![Actions Status](https://github.com/jest-community/jest-junit/actions/workflows/nodejs.yml/badge.svg?branch=master)](https://github.com/jest-community/jest-junit/actions)\n\n# jest-junit\nA Jest reporter that creates compatible junit xml files\n\nNote: as of jest-junit 11.0.0 NodeJS >= 10.12.0 is required.\n\n## Installation\n```shell\nnpm install --save-dev jest-junit\n```\n\n## Usage\nIn your jest config add the following entry:\n```JSON\n{\n  \"reporters\": [ \"default\", \"jest-junit\" ]\n}\n```\n\nThen simply run:\n\n```shell\njest\n```\n\nFor your Continuous Integration you can simply do:\n```shell\njest --ci --reporters=default --reporters=jest-junit\n```\n\n## Usage as testResultsProcessor (deprecated)\nThe support for `testResultsProcessor` is only kept for [legacy reasons][test-results-processor] and might be removed in the future.\nYou should therefore prefer to configure `jest-junit` as a _reporter_.\n\nShould you still want to, add the following entry to your jest config:\n```JSON\n{\n  \"testResultsProcessor\": \"jest-junit\"\n}\n```\n\nThen simply run:\n\n```shell\njest\n```\n\nFor your Continuous Integration you can simply do:\n```shell\njest --ci --testResultsProcessor=\"jest-junit\"\n```\n\n## Configuration\n\n`jest-junit` offers several configurations based on environment variables or a `jest-junit` key defined in `package.json` or a reporter option.\nEnvironment variable and package.json configuration should be **strings**.\nReporter options should also be strings exception for suiteNameTemplate, classNameTemplate, titleNameTemplate that can also accept a function returning a string.\n\n| Environment Variable Name | Reporter Config Name| Description | Default | Possible Injection Values\n|---|---|---|---|---|\n| `JEST_SUITE_NAME` | `suiteName` | `name` attribute of `<testsuites>` | `\"jest tests\"` | N/A\n| `JEST_JUNIT_OUTPUT_DIR` | `outputDirectory` | Directory to save the output. Relative path outside of project root (e.g. in monorepos) has to be prefixed with `<rootDir>` literal, e.g. `<rootDir>/../coverage` | `process.cwd()` | N/A\n| `JEST_JUNIT_OUTPUT_NAME` | `outputName` | File name for the output. | `\"junit.xml\"` | N/A\n| `JEST_JUNIT_OUTPUT_FILE` | `outputFile` | Fullpath for the output. If defined, `outputDirectory` and `outputName` will be overridden | `undefined` | N/A\n| `JEST_JUNIT_UNIQUE_OUTPUT_NAME` | `uniqueOutputName` | Create unique file name for the output leveraging the `outputName` as a prefix if given `${outputName}-${uuid}.xml` or a default of `junit.xml-${uuid}.xml` if `outputName` is not specified, overrides `outputName` | `false` | N/A\n| `JEST_JUNIT_SUITE_NAME` | `suiteNameTemplate` | Template string for `name` attribute of the `<testsuite>`. | `\"{title}\"` | `{title}`, `{filepath}`, `{filename}`, `{displayName}`\n| `JEST_JUNIT_CLASSNAME` | `classNameTemplate` | Template string for the `classname` attribute of `<testcase>`. | `\"{classname} {title}\"` | `{classname}`, `{title}`, `{suitename}`, `{filepath}`, `{filename}`, `{displayName}`\n| `JEST_JUNIT_TITLE` | `titleTemplate` | Template string for the `name` attribute of `<testcase>`. | `\"{classname} {title}\"` | `{classname}`, `{title}`, `{filepath}`, `{filename}`, `{displayName}`\n| `JEST_JUNIT_ANCESTOR_SEPARATOR` | `ancestorSeparator` | Character(s) used to join the `describe` blocks. | `\" \"` | N/A\n| `JEST_JUNIT_ADD_FILE_ATTRIBUTE` | `addFileAttribute` | Add file attribute to the output (validated on CIRCLE CI and GitLab CI). Must be a string. | `\"false\"` | N/A\n| `JEST_JUNIT_FILE_PATH_PREFIX` | `filePathPrefix` | Prefix to add to the test suite file path. The value will be prefixed using `path.join`. Useful in case of monorepo | `\"\"` | N/A\n| `JEST_JUNIT_INCLUDE_CONSOLE_OUTPUT` | `includeConsoleOutput` | Adds console output to any testSuite that generates stdout during a test run. | `false` | N/A\n| `JEST_JUNIT_INCLUDE_SHORT_CONSOLE_OUTPUT` | `includeShortConsoleOutput` | Adds short console output (only message value) to any testSuite that generates stdout during a test run. | `false` | N/A\n| `JEST_JUNIT_REPORT_TEST_SUITE_ERRORS` | `reportTestSuiteErrors` | Reports test suites that failed to execute altogether as `error`. _Note:_ since the suite name cannot be determined from files that fail to load, it will default to file path.| `false` | N/A\n| `JEST_JUNIT_NO_STACK_TRACE` | `noStackTrace` | Omit stack traces from test failure reports, similar to `jest --noStackTrace` | `false` | N/A\n| `JEST_USE_PATH_FOR_SUITE_NAME` | `usePathForSuiteName` | **DEPRECATED. Use `suiteNameTemplate` instead.** Use file path as the `name` attribute of `<testsuite>` | `\"false\"` | N/A\n| `JEST_JUNIT_TEST_CASE_PROPERTIES_JSON_FILE` | `testCasePropertiesFile` | Name of the custom testcase properties file | `\"junitProperties.js\"` | N/A\n| `JEST_JUNIT_TEST_CASE_PROPERTIES_DIR` | `testCasePropertiesDirectory` | Location of the custom testcase properties file | `process.cwd()` | N/A\n| `JEST_JUNIT_TEST_SUITE_PROPERTIES_JSON_FILE` | `testSuitePropertiesFile` | Name of the custom testsuite properties file | `\"junitTestCaseProperties.js\"` | N/A\n| `JEST_JUNIT_TEST_SUITE_PROPERTIES_DIR` | `testSuitePropertiesDirectory` | Location of the custom testsuite properties file | `process.cwd()` | N/A\n\n\nYou can configure these options via the command line as seen below:\n\n```shell\nJEST_SUITE_NAME=\"Jest JUnit Unit Tests\" JEST_JUNIT_OUTPUT_DIR=\"./artifacts\" jest\n```\n\nOr you can also define a `jest-junit` key in your `package.json`.  All are **string** values.\n\n```\n{\n  ...\n  \"jest-junit\": {\n    \"suiteName\": \"jest tests\",\n    \"outputDirectory\": \".\",\n    \"outputName\": \"junit.xml\",\n    \"uniqueOutputName\": \"false\",\n    \"classNameTemplate\": \"{classname}-{title}\",\n    \"titleTemplate\": \"{classname}-{title}\",\n    \"ancestorSeparator\": \" › \",\n    \"usePathForSuiteName\": \"true\"\n  }\n}\n```\n\nOr you can define your options in your reporter configuration.\n\n```js\n// jest.config.js\n{\n  reporters: [\n    \"default\",\n    [ \"jest-junit\", { suiteName: \"jest tests\" } ]\n  ]\n}\n```\n\n\n### Configuration Precedence\nIf using the `usePathForSuiteName` and `suiteNameTemplate`, the `usePathForSuiteName` value will take precedence. ie: if `usePathForSuiteName=true` and `suiteNameTemplate=\"{filename}\"`, the filepath will be used as the `name` attribute of the `<testsuite>` in the rendered `jest-junit.xml`).\n\n### Examples\n\nBelow are some example configuration values and the rendered `.xml` to created by `jest-junit`.\n\nThe following test defined in the file `/__tests__/addition.test.js` will be used for all examples:\n```js\ndescribe('addition', () => {\n  describe('positive numbers', () => {\n    it('should add up', () => {\n      expect(1 + 2).toBe(3);\n    });\n  });\n});\n```\n\n#### Example 1\nThe default output:\n\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:42:28\" time=\"0.161\">\n    <testcase classname=\"addition positive numbers should add up\" name=\"addition positive numbers should add up\" time=\"0.004\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n#### Example 2\nUsing the `classNameTemplate` and `titleTemplate`:\n\n```shell\nJEST_JUNIT_CLASSNAME=\"{classname}\" JEST_JUNIT_TITLE=\"{title}\" jest\n```\n\nrenders\n\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:45:42\" time=\"0.154\">\n    <testcase classname=\"addition positive numbers\" name=\"should add up\" time=\"0.005\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n#### Example 3\nUsing the `ancestorSeparator`:\n\n```shell\nJEST_JUNIT_ANCESTOR_SEPARATOR=\" › \" jest\n```\nrenders\n\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:47:12\" time=\"0.162\">\n    <testcase classname=\"addition › positive numbers should add up\" name=\"addition › positive numbers should add up\" time=\"0.004\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n#### Example 4\nUsing the `suiteNameTemplate`:\n\n```shell\nJEST_JUNIT_SUITE_NAME =\"{filename}\" jest\n```\n\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition.test.js\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:42:28\" time=\"0.161\">\n    <testcase classname=\"addition positive numbers should add up\" name=\"addition positive numbers should add up\" time=\"0.004\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n\n#### Example 5\nUsing `classNameTemplate` as a function in reporter options\n\n```js\n// jest.config.js\n{\n  reporters: [\n    \"default\",\n      [\n        \"jest-junit\",\n        {\n          classNameTemplate: (vars) => {\n            return vars.classname.toUpperCase();\n          }\n        }\n      ]\n  ]\n}\n```\n\nrenders\n\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:42:28\" time=\"0.161\">\n    <testcase classname=\"ADDITION POSITIVE NUMBERS\" name=\"addition positive numbers should add up\" time=\"0.004\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n#### Adding custom testsuite properties\nNew feature as of jest-junit 11.0.0!\n\nCreate a file in your project root directory named junitProperties.js:\n```js\nmodule.exports = () => {\n  return {\n    key: \"value\",\n  };\n};\n```\n\nWill render\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:42:28\" time=\"0.161\">\n    <properties>\n      <property name=\"key\" value=\"value\" />\n    </properties>\n    <testcase classname=\"addition positive numbers should add up\" name=\"addition positive numbers should add up\" time=\"0.004\">\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\n#### Adding custom testcase properties\n\nCreate a file in your project root directory named junitTestCaseProperties.js:\n```js\nmodule.exports = (testResult) => {\n  return {\n    \"dd_tags[test.invocations]\": testResult.invocations,\n  };\n};\n```\n\nWill render\n```xml\n<testsuites name=\"jest tests\">\n  <testsuite name=\"addition\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"0\" timestamp=\"2017-07-13T09:42:28\" time=\"0.161\">\n    <testcase classname=\"addition positive numbers should add up\" name=\"addition positive numbers should add up\" time=\"0.004\">\n      <properties>\n        <property name=\"dd_tags[test.invocations]\" value=\"1\" />\n      </properties>\n    </testcase>\n  </testsuite>\n</testsuites>\n```\n\nWARNING: Properties for testcases is not following standard JUnit XML schema.\nHowever, other consumers may support properties for testcases like [DataDog metadata through `<property>` elements](https://docs.datadoghq.com/continuous_integration/tests/junit_upload/?tab=jenkins#providing-metadata-through-property-elements)\n\n[test-results-processor]: https://github.com/jest-community/jest-junit/discussions/158#discussioncomment-392985\n","publish_time":1777038036740,"_cnpm_publish_time":1777038036740,"dist-tags":{"latest":"17.0.0"}}