#Legacy Debugger
Uses meld
to unobtrusively add specs to class methods. Made for legacy-ish large objects in the browser. Comes with customizable logging for different browsers (defaults to chrome).
#Usage
<script src="node_modules/legacy-debugger/dist/legacy-debugger.min.js"></script>
var testRunner = new LegacyDebugger({
target: {object},
tests: {array},
logTemplateString: {string},
logStyle: {string},
logPlaceholders: {object}
});
#Options
-
target {object} (required)
- object literal, each method in object will be advised withmeld.around
. -
tests {array} (required)
- each object literal in the array must have amethod {string}
property that identifies which method the spec will be run on, and aspec {function}
method that will be advised on the method. Thespec
method is supplied with an object that contains the arguments of the original method call so you can programatically make assertions (as you usually would...). The context of thespec
method containsthis.assert
which is the entire chai library. logTemplateString {string} (optional)
- template string for pretty browser logging, defaults to[result] [targetMethod] [expected] [actual] [message] [stackStr]
-
logStyle {string} (optional)
- which browser to log in, defaults tochrome
logPlaceholders {object} (optional)
- provide customizable pretty color logging, only tested in chrome, see./lib/logPlaceholders.js
for defaults
#Example
var target = {
add: function(one, two) {
return one + two;
},
multiply: function(one, two) {
return one * two;
},
subtract: function(one, two) {
return one - two;
}
};
var test = new LegacyDebugger({
target: target,
tests: [
{
method: 'add',
spec: function(details) {
this.assert.strictEqual(1, 1, '1 is 1');
this.assert.strictEqual(1, 2, '1 is 1');
this.assert.strictEqual(1, 3, '1 is 1');
this.assert.strictEqual(1, 1, '1 is 1');
this.assert.strictEqual(1, 1, '1 is 1');
this.assert.strictEqual(1, 1, '1 is 1');
this.assert.strictEqual(1, 1, '1 is 1');
}
},
{
method: 'multiply',
spec: function(details) {
this.assert.strictEqual(true, false, 'true is not false');
this.assert.strictEqual(true, false, 'true is not false');
this.assert.strictEqual(true, false, 'true is not false');
this.assert.strictEqual(true, false, 'true is not false');
}
}
]
});
target.add(1, 2);
target.add(14, 45);
target.multiply(14, 45);
target.subtract(23, 3);
target.subtract(23, 52);
#Building
$git clone <this repo>
$npm i
$npm test
$npm run build-development
$npm run build-production
#Todo
Add instance logging based on specific results
Custom tmpl string broken