Closed smmehadi closed 9 years ago
You're probably best off instrumenting the JavaScript using file-mode.
The coverage object can then be obtained using jscoverage_serializeCoverageToJSON()
as described in the manual.
Thanks for replying, and apologies for asking basic question. can you please tell me what is the command to instrument (in file-mode). tried executing this command: java -jar target/dist/JSCover-all.jar -fs doc/example target/example it gives this output: Jul 27, 2015 2:55:28 PM jscover.Main runMain INFO: Args: -fs,doc/example,target/example
also my application doesn't have a url bar, but in manual everywhere it is mentioned to navigate to http://localhost:8080 what should i do in case of desktop application, which doesn't have a url bar?
Try executing the JavaScript code jscoverage_serializeCoverageToJSON()
to see if you can get the coverage data.
So i was able to instrument the js files using:
java -jar target/dist/JSCover-all.jar -fs doc/<
I replaced these instrumented files (<
or i execute jscoverage_serializeCoverageToJSON() in response to some button click in my application UI, and write its returned value using document.write(json). Are the steps written above correct or needs some modifications?
The coverage is stored in JavaScript, so the steps you described sound correct. The string that is returned goes in a file called jscoverage.json
which can then be converted to Cobertura XML, LCOV, or viewed directly with accompanying JSCover report files (e.g. jscoverage.html
, jscoverage.js
- NB the file mode generated jscoverage.js
needs jscoverage_isReport = true;
appended to view the report).
Thanks a lot for help, that worked. one more question is if in each jscoverage_serializeCoverageToJSON() function (during instrumentation), i want to insert couple of more javascript statements (like sending coverage result to a server), then in which file i have to make changes.
The function jscoverage_report
will serialize and POST the data to the current server at /jscoverage-store
if that's any help.
We have a desktop application which renders html/javascript in CEF (chromium embedded framework). Now we want to measure javascript code coverage for it. How should we go for it.
All the current page talk about javascript code coverage in browser only, but i haven't found anything for dekstop applications rendering html/javascript.