This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

legacy-debugger

0.0.2 • Public • Published

#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 with meld.around.
  • tests {array} (required) - each object literal in the array must have a method {string} property that identifies which method the spec will be run on, and a spec {function} method that will be advised on the method. The spec 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 the spec method contains this.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 to chrome
  • 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

Readme

Keywords

none

Package Sidebar

Install

npm i legacy-debugger

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • daniellizik