Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jest-sonar

sh33dafi750kMIT0.2.16

A sonar reporter for jest

jest, sonar, sonarqube, test, report

readme

jest-sonar

jest-sonar is a custom test reporter for Jest. It converts the generated report into Sonar's Generic Execution format.

CodeQL Maintainability Test Coverage

Installation

Using yarn:

$ yarn add -D jest-sonar

Using npm:

$ npm i -D jest-sonar

Configuration

Configure Jest in your jest.config file and add jest-sonar to the list of reporters.

module.exports = {
    ...
    reporters: ['default',  'jest-sonar'],
    ...
}

Customize the reporter

The following options can be set to customize the reporter:

Option Environment override Description Default Accepted values
outputDirectory JEST_SONAR_OUTPUT_DIR The directory to which the report should be written The projects root dir string
outputName JEST_SONAR_OUTPUT_NAME The name of the report sonar-report.xml string
reportedFilePath JEST_SONAR_REPORTED_FILE_PATH Should the path be relative or absolute 'relative' 'relative' or 'absolute'
relativeRootDir JEST_SONAR_RELATIVE_ROOT_DIR The root directory for the relative path jest rootDir string

You can set these options when defining the reporter in jest.config:

module.exports = {
    ...
        reporters: ['default',  ['jest-sonar', {
            outputDirectory: 'my/custom/directory',
            outputName: 'my-new-report-name.xml',
            reportedFilePath: 'absolute'
        }]],
    ...
}

Or you can override these options via environment variables. Environment variables will always take precedence over options set via jest.config

$ JEST_SONAR_OUTPUT_DIR=./specialDir/ npm run jest

Contribution

Contribution guidelines for this project

Contributions to this project are welcome, either by submitting bug reports, submitting feature requests or submitting pull requests.

Creating a pull request

  1. Fork the repo on GitHub
  2. Clone and make changes on your machine
  3. Commit and Push the changes to your fork
  4. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest change from "upstream" before making a pull request!

Licence

This project uses the MIT license.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.2.16 (2023-04-21)

Features

  • added ability to override options via env (04d333a)

0.2.15 (2022-12-11)

Features

  • #36: respect <rootDir> in outputDirectory (5257cff), closes #36

0.2.14 (2022-12-09)

0.2.13 (2022-12-09)

0.2.12 (2021-02-09)

Bug Fixes

  • #31: fixes #31 issue with null duration (5238733)

0.2.11 (2020-09-14)

Features

  • added ability specify root directory for relative path (d1b318b)

0.2.10 (2020-07-14)

0.2.9 (2020-07-03)

Features

  • #23: added reportedFilePath to config (983b5e2), closes #23

0.2.8 (2020-05-10)

Security

  • Updated versions of dependencies that had vulnerabilities.

0.2.7 (2020-04-25)

Bug Fixes

  • #20: use coverage directory to generate report (33adbd2), closes #20

0.2.6 (2020-04-25)

Bug Fixes

  • #13: escaped chars in failure (642813b), closes #13

0.2.5 (2020-03-06)

Bug Fixes

  • reporter: support empty test suites (6fc69f1)

0.2.4 (2019-09-07)

0.2.3 (2019-09-07)

0.2.2 (2019-08-26)

0.2.1 (2019-08-12)

Bug Fixes

  • Escaped strings inside attributes (99add1c)

0.2.0 (2019-08-01)

Bug Fixes

  • report: Rewrote how to create a dir recusivly so we are compatible with node < 10 (e662b9c)

Features

  • reporter: Added output for skipped tests (60d1b40)

0.1.3 (2019-07-30)

Bug Fixes

  • report: Rewrote how to create a dir recusivly so we are compatible with node < 10 (e662b9c)

0.1.1 (2019-07-11)

0.1.0 (2019-07-10)

Bug Fixes

  • reporter: Fixed exception when not providing an outputDirectory (7e7e0b0)

0.0.2 (2019-07-09)

0.0.1 (2019-07-09)