SonarQube build configuration and code coverage for javascript in .net 4.8 framework

This is regarding the SonarQube build configuration.

We bought the SonarQube developer edition license for our company recently and configured our code, which was developed in the.Net Framework 4.8. Our code has c#, Vb, css, js, xml, and rdlc files, and the SonarQube report demanded code coverage for only javascript files. So we have used the JEST testing framework along with the React for writing the code coverage. We could not have both the React Jest framework and .net 4.8 framework. Kindly advise on how to move forward on this issue.

Note: Javascript code coverage was not supported by the .net testing frameworks like NUnit, XUnit so we used JEST testing framework.

Hey there.

I don’t quite understand your question. Are you facing issues importing coverage on .NET code, Javascript code, or both?

Hi ,

I need to build the code written on react jest framework along with my existing dotnet code written on 4.8 framework. I have opted react jest framework since NUnit or XUnit testing framework doesn’t support for javascript code coverage. Can we able to build react jest code and dotnet framework build in same branch for code coverage. SonarQube mapped branch require code coverage as 0.0 only for javascript files in the project not for the other files like c#, vb.net, css and XML. And testing framework in dotnet framework like NUnit and XUnit not supporting for javascript code coverage.

Thanks
John Rathies

You can enrich your analysis with javascript coverage results, as long as you pass a valid report generated during your build to the right analysis parameter. For that, see the documentation on J JavaScript/TypeScript test coverage.

I can able to generate the code coverage from the React-JEST framework separately i am facing issue only when i am combining the React-JEST code with .net projects developed in 4.8 framework build not generating so SonarQube build fails. Please confirm the below,

  1. UI project (React-JEST) and .net framework 4.8 project solution combined in a single branch for generating SonarQube code coverage report ?

  2. Can have the UI project(React-JEST) in a separate branch and map the code coverage XML to .net framework 4.8 project ?

kindly assist on this.

Thanks
John Rathies

I’m having a really hard time understanding your questions. Maybe you can share logs and screenshot to help demonstrate the issue.

Hi Colin,

Sorry for the inconvenience .

Can we utilise the JEST testing framework separately in a branch to assess code coverage for JavaScript files in our .NET project, while still employing NUnit, XUnit, or Unit for code coverage assessment in C# or VB files as per SonarQube requirements?

Can we utilise the JEST testing framework separately in a branch to assess code coverage for JavaScript files in our .NET project, while still employing NUnit, XUnit, or Unit for code coverage assessment in C# or VB files as per SonarQube requirements?

You can do whatever you want in your build. If you’re producing code coverage files for Javascript, you can pass those to the analysis parameters defined here.

SonarQube only consumes the coverage reports, it’s not involved in producing them. If you’re facing failures in your build independent of SonarQube, you’'ll have to sort those out on your own.

Hi Colin,

Thank you for the update
In the SonarQube dashboard, despite observing 29 passed tests in the test explorer for our .NET Framework 4.8 application, the coverage remains reported as 0.0. We’ve specified the coverage report XML file location in our build rules:

NUnit Test Coverage

sonar.cs.nunit.reportsPaths=coverage_report.xml
Please advise on how to properly map the coverage report XML file.

What do you see in the Overall Code tab? It may just (accurately) be the case that on the 12 lines that are New Code there is no coverage, but there is some coverage being reported for the rest of your project.

Your last analysis also had warnings – what are they?