Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fixed progress report for IE8<=.

Guillermo Rauch6e11aa9d159b
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index e118be7b..fc564ac8 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -43,11 +43,18 @@ function HTML(runner) {
, stack = [root]
, stat = $(statsTemplate).appendTo(root)
, canvas = stat.find('canvas').get(0)
- , ctx = canvas.getContext('2d')
- , progress = new Progress;
+ , ctx, progress
+
+ if (canvas.getContext) {
+ ctx = canvas.getContext('2d');
+ progress = new Progress;
+ }
if (!root.length) return error('#mocha div missing, add it to your document');
- progress.size(50);
+
+ if (progress) {
+ progress.size(50);
+ }
runner.on('suite', function(suite){
if (suite.root) return;
@@ -74,8 +81,10 @@ function HTML(runner) {
// TODO: add to stats
var percent = stats.tests / total * 100 | 0;
- // update progress bar
- progress.update(percent).draw(ctx);
+ if (progress) {
+ // update progress bar
+ progress.update(percent).draw(ctx);
+ }
// update stats
var ms = new Date - stats.start;
@@ -135,4 +144,4 @@ function clean(str) {
.replace(/^\s+/, '');
return str;
-}
\ No newline at end of file
+}