I am using the following:
“sonarqube-scanner”: “^2.5.0”
“vue-jest”: “^3.0.6”
“jest”: “^23.6.0”
“@vue/test-utils”: “^1.0.3”
I have my Vue template html split from the javascript that contains the methods etc into two separate files. The Vue template html is in a .vue file with a reference to the javascript file that contains the methods, which is a separate .js file, exactly as it is mentioned in the vue documentation here:
I have created jest unit tests that mount the aforementioned vue component, and successfully test the methods that are in that component, the code of which are contained in the separated .js file as mentioned above. The sonar scan is completing successfully, however in the sonar report of coverage, the lines of code that the unit tests are testing, are never being reported as “covered” within that javascript file.
I would like that separate javascript file to come up as having it’s lines covered when they are in fact covered, where right now it is being analysed by sonar, but continue to report back that the lines are not being covered. I’ve tried many different ways of setting up the tests, but believe this is a configuration issue in sonar, or an error within the scanner.
Hi @bweller, welcome to the SonarSource Community!
You never mentioned if you’re actually passing a coverage report of some kind to SonarQube during the analysis. As you can see in our Test Coverage & Execution docs, each language has one or more supported formats for capturing the coverage data. For Javascript, it’s LCOV. Without a report supplied to the scanner, we don’t do anything to automagically pick up coverage data.
We also have a generic coverage format if you have something other than LCOV and are able to translate it.
Hi Jeff,
Thanks for your response. I am providing the coverage report using lcov to SonarQube, and in the SonarQube report it is showing the javascript file as being successfully scanned, but having all of it’s lines “not covered”.
Then the next thing to check is what the path describing the javascript file(s) looks like in the LCOV report compared to how SonarQube sees it. If the path is relative to a different root folder, that can cause SQ to not realize it’s describing the “same” file.