Coverage for Vue component's separate Javascript file

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.

Any assistance would be greatly appreciated.

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.

In one of our guides there’s mention of a converter to take Jest reports and convert them to our generic format; this may suit your needs.

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.

I’ve checked the paths in paths in both the LCOV report and how SonarQube sees it. Both are the same.

Would you mind posting a log of an analysis in DEBUG mode, as well as the LCOV file?

Is there a way i could send them to you privately as to not post it publicly, then post the solution when we find it?