Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve LCOV reporter and fix bug when toHTML set to false #432

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/reporters/lcov_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var body = document.body;

var appendHtml = function(filename, data, toHTML) {
var appendResult = function(filename, data, options) {

var str = "";
str += 'SF:' + filename + '\n';
Expand All @@ -20,26 +20,24 @@

str += 'end_of_record\n';

if (toHTML) {
if (options.toHTML) {
var div = document.createElement('div');
div.className = "blanket_lcov_reporter";
div.innerText = str;
body.appendChild(div);
} else {
window._$blanket_LCOV = str;
window._$blanket_LCOV = (window._$blanket_LCOV || '') + str;
}
};

blanket.customReporter = function(coverageData, options) {
var toHTML = true;

if (typeof options !== 'undefined' && typeof options.toHTML !== 'undefined') {
toHTML = options.toHTML;
}
options = options || {
toHTML: true
};

for (var filename in coverageData.files) {
var data = coverageData.files[filename];
appendHtml(filename, data, toHTML);
appendResult(filename, data, options);
}
};

Expand Down