added assertion counter to Mocha

This commit is contained in:
Eric Rowell
2013-09-30 07:52:13 -07:00
parent 5caea0c2a2
commit 1965f61da2

View File

@@ -1,6 +1,47 @@
mocha.ui('tdd');
var assert = chai.assert,
kineticContainer = document.getElementById('kinetic-container');
kineticContainer = document.getElementById('kinetic-container'),
origAssertEqual = assert.equal,
origAssert = assert,
origNotEqual = assert.notEqual,
assertionCount = 0,
assertions = document.createElement('em');
function init() {
// assert extenders so that we can count assertions
assert = function() {
origAssert.apply(this, arguments);
assertions.innerHTML = ++assertionCount;
};
assert.equal = function() {
origAssertEqual.apply(this, arguments);
assertions.innerHTML = ++assertionCount;
};
assert.notEqual = function() {
origNotEqual.apply(this, arguments);
assertions.innerHTML = ++assertionCount;
};
window.onload = function() {
var mochaStats = document.getElementById('mocha-stats');
if (mochaStats) {
var li = document.createElement('li');
var anchor = document.createElement('a');
anchor.href = '#';
anchor.innerHTML = 'assertions:';
assertions.innerHTML = 0;
li.appendChild(anchor);
li.appendChild(assertions);
mochaStats.appendChild(li);
}
}
}
Kinetic.enableTrace = true;
// make sure pixel ratio is 1 or else the tests will fail on devices with retina display
@@ -46,4 +87,6 @@ beforeEach(function(){
Kinetic.inDblClickWindow = false;
Kinetic.DD.isDragging = false;
Kinetic.DD.node = undefined;
});
});
init();