diff --git a/src/tabulate.js b/src/tabulate.js index 07cd0f5e..adacf74f 100644 --- a/src/tabulate.js +++ b/src/tabulate.js @@ -42,14 +42,18 @@ function toFolder(path) { } function getStatement(file) { - const { branches, functions, lines } = file; - return [branches, functions, lines].reduce((prev, curr) => ({ - hit: prev.hit + (curr.hit || 0), - found: prev.found + (curr.found || 0), - }), { - hit: 0, - found: 0, - }) + const { branches, functions, lines } = file + + return [branches, functions, lines].reduce(function(acc, curr) { + if (!curr) { + return acc + } + + return { + hit: acc.hit + curr.hit, + found: acc.found + curr.found, + } + }, { hit: 0, found: 0 }) } function toRow(file, indent, options) { diff --git a/src/tabulate_test.js b/src/tabulate_test.js index 814f550b..eee1f1b5 100644 --- a/src/tabulate_test.js +++ b/src/tabulate_test.js @@ -125,6 +125,7 @@ test("tabulate should generate a correct table", function() { tbody( tr( th("File"), + th("Stmts"), th("Branches"), th("Funcs"), th("Lines"), @@ -139,12 +140,13 @@ test("tabulate should generate a correct table", function() { "index.js", ), ), + td("100%"), td("N/A"), td("100%"), td("N/A"), td(), ), - tr(td({ colspan: 5 }, b("src"))), + tr(td({ colspan: 6 }, b("src"))), tr( td( "   ", @@ -155,6 +157,7 @@ test("tabulate should generate a correct table", function() { "foo.js", ), ), + td(b("89.66%")), td("100%"), td(b("66.67%")), td(b("91.30%")), @@ -167,7 +170,7 @@ test("tabulate should generate a correct table", function() { ), ), ), - tr(td({ colspan: 5 }, b("src/bar"))), + tr(td({ colspan: 6 }, b("src/bar"))), tr( td( "   ", @@ -178,6 +181,7 @@ test("tabulate should generate a correct table", function() { "baz.js", ), ), + td(b("53.85%")), td("N/A"), td(b("66.67%")), td(b("50%")),