tntim96/JSCover

Aggregated JavaScript Files

Closed this issue · 4 comments

Hello,

We would like to add JS code coverage for our project. All tests are using Selenium WebDriver and we're using ExtJS Javascript framework as front-end (Java as back-end).
Currently we aggregate all js files in one (app.js) before doing all integration tests. We're using Jacoco for Java code coverage and SonarQube as quality server (Jenkins as CI server, Maven3 for dependencies management). The goal is to see JS code coverage in Sonar per file.

JSCover seems to be the perfect library to get JS code coverage but we have few questions:

  1. Could we still aggregate all files in one? I think we can't because of instrumentation system per line
  2. Same question about minification?
  3. If 1. and 2. aren't possible, do you plan to change your instrument system to a statement one? We saw you're are considering it in others issues or JSCover2
  4. What is the best mode to get code coverage? Instrument files before launching tests or using the server proxy? What about performance?
  5. Should we use the jscover maven plugin?

Best regards,
JB

You can do this by instrumenting the JS before you do any JS processing (i.e. aggregation and concatenation, minification).

What is the best mode to get code coverage?

You'll have to use file-mode (which is fine).

Should we use the jscover maven plugin?

No, JSCover JAR is fine.

Thank you for this quick answer.

If we do like you said :

  1. Instrument all js files with JSCover
  2. Aggregate, concatenate and minify all js files in one js file
  3. Launch the integration tests
  4. Retrieve the code coverage from JSCover and inject it in Sonar

Will we be able to see code coverage on original source files? How does it work?

Will we be able to see code coverage on original source files?

Yes.

How does it work?

Can you be more specific? Read through the documentation and try the examples, and hopefully it will be clear.

It works because JSCover is using file path as array key (_$jscoverage).

Thank you, everything is working fine. I can now see the JS code coverage in Sonar. Great tool, great job, great support, everybody should like JSCover!