jest-sonar

A sonar reporter for jest

Usage no npm install needed!

<script type="module">
  import jestSonar from 'https://cdn.skypack.dev/jest-sonar';
</script>

README

jest-sonar

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

Build Status CodeQL Maintainability Test Coverage

Installation

Using yarn:

$ yarn install -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 Description Default Accepted values
outputDirectory The directory to which the report should be written The projects root dir string
outputName The name of the report sonar-report.xml string
reportedFilePath Should the path be relative or absolute 'relative' 'relative' or 'absolute'
relativeRootDir 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'
        }]],
    ...
}

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.