Javascript Code Coverage
abstract
Sahi Pro can collect Javascript Code Coverage metrics of the web application under test.
This feature is available since Sahi Pro v7.0.0
infoNote: If the script is navigating to more than one domain, then to collect Javascript Code Coverage for each domain,
_addToSession API needs to be added for each domain in the script. Otherwise, Sahi collects Javascript Code Coverage only for first domain.
Enable JS Code Coverage
Enable for all scripts/suites
Code coverage can be enabled globally by settingjs.code_coverage.enabled.default=true
in sahi_pro/userdata/config/userdata.properties
Enable at suite/script run
Check the checkbox inPlayback Properties -> Show advanced settings -> JS Code Coverage
![](../assets/images/using-sahi/js_code_coverage_checkbox.png)
JS Code Coverage Report
Click onJS Code Coverage Report
link on Suite Report and Script Report pages.
![](../assets/images/using-sahi/js_code_coverage_report_link.png)
![Code coverage](../assets/images/using-sahi/code_coverage.png)
infoIf the percentage of function covered is below 50% then it appears in red colour otherwise it appears in green colour.
Clicking on a particular js file shows count against each function and decision point:
![](../assets/images/using-sahi/function_call.png)