SonarQube Gradle Jest Sonar Properties

The following is what I have for Coverage for my React JavaScript application. I am getting coverage locally with npm test, but not reported in SonarQube. Can someone help me with what I am missing?

Gradle

// gradle sonar plugin configuration
apply plugin: 'org.sonarqube'
sonarqube {
    properties {
        property "sonar.projectName", "${project_name}-${version}"
        property "sonar.projectKey", "${project_name}-${version}"
		property "sonar.sources", "src/main/java/com/company/wcp,src/main/webapp/wcpwave2/src"
		property "sonar.exclusions", "src/main/webapp/wcpwave2/src/assets/**"
		// Where to find tests file, also src
		property "sonar.tests", "src/main/java/com/company/wcp,src/main/webapp/wcpwave2/src"
		// But we get specific here
		// We don't need to exclude it in sonar.sources because it is automatically taken care of
		property "sonar.test.inclusions", "src/**/*.spec.js,src/**/*.spec.jsx,src/**/*.test.js,src/**/*.test.jsx"

		// Now specify path of lcov and testlog
		property "sonar.javascript.lcov.reportPaths", "src/main/webapp/wcpwave2/coverage/lcov.info"
		//property "sonar.testExecutionReportPaths", "src/main/webapp/wcpwave2/coverage/coverage-final.json"
    }
}

sonar-project.properties

# Source
sonar.sources=src
# Where to find tests file, also src
sonar.tests=src
# But we get specific here
# We don't need to exclude it in sonar.sources because it is automatically taken care of
sonar.test.inclusions=src/**/*.spec.js,src/**/*.spec.jsx,src/**/*.test.js,src/**/*.test.jsx

# Now specify path of lcov and testlog
sonar.javascript.lcov.reportPaths=coverage/jest/lcov.info
#sonar.testExecutionReportPaths=coverage/jest/testlog.xml

package.json

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "jest --coverage",
    "eject": "react-scripts eject"
  },
  "jest": {
    "transform": {
      "^.+\\.[t|j]sx?$": "babel-jest"
    },
    "collectCoverage": true,
    "testResultsProcessor":"jest-sonar-reporter"
  },
  "homepage": "./",
  "devDependencies": {
    "jest": "^24.9.0",
    "jest-junit-reporter": "^1.1.0"
  }

Hi,

Welcome to the community!

Can you show us your analysis log?

 
Ann

Can you provide more details on where I would find these logs? I am not the administrator of the SonarQube instance.

Hi,

The analysis log is output by/on your build agent.

 
Ann

I hope this might help. I am getting the report form Jest running npm test

$ npm test

> dynamic-form@0.1.0 test C:\Users\UID\source\repos\appName\src\main\webapp\appwave2
> jest --coverage --testResultsProcessor jest-sonar-reporter

 PASS  src/components/Banner.test.js (9.608s)
 PASS  src/api/apiConfig.test.js (9.867s)
--------------|----------|----------|----------|----------|-------------------|
File          |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------|----------|----------|----------|----------|-------------------|
All files     |      100 |       50 |      100 |      100 |                   |
 apiConfig.js |      100 |       50 |      100 |      100 |... 21,22,23,24,25 |
--------------|----------|----------|----------|----------|-------------------|

Test Suites: 2 passed, 2 total
Tests:       23 passed, 23 total
Snapshots:   0 total
Time:        23.454s
Ran all test suites.

I have not applied a lot of tests because I want to ensure SonarQube is reporting.

appWave2/reports/test-report.xml

It is providing XML, but I cannot post as this would violate policy.

Hi,

That’s not what I’m looking for. I’m looking for what’s logged as a result of the analysis command.

 
Ann