!function() {}(STITCH);function PadTestLogger() { this.testOutput = []; } PadTestLogger.prototype.log = function(msg) { this.testOutput.push(msg); }; function TestRunner(logger, assert) { this.log = logger.log.bind(logger); this.assert = assert; this.initTests(); } TestRunner.prototype.initTests = function() { this.tests = []; }; TestRunner.prototype.addTest = function(name, testFunc) { this.tests.push({ name: name, testFunc: testFunc }); }; TestRunner.prototype.runTests = function() { this.tests.forEach(function(test) { try { test.testFunc(this.assert); this.log('PASS - ' + test.name + '.'); STITCH.inc_passed(); } catch(e) { var errorMessage = "expected: " + JSON.stringify(e.expected) + "\r actual: " + JSON.stringify(e.actual); // parse e.messsage - if it has a custom message show only the custom message, // otherwise show the chai error message. var e_message = e.message; var e_message_i = e_message.lastIndexOf(':'); if (e_message_i > 0) { e_message = e_message.substring(0, e_message_i); } this.log('FAIL - ' + test.name + '.' + "\r message: " + e_message + "\r " + errorMessage); STITCH.inc_failed(); } }.bind(this)); }; // Actual use of the test harness const logger = new PadTestLogger(); const runner = new TestRunner(logger, chai.assert);/* runner.addTest('my test that is guaranteed to blow up', function(assert) { // actual test code goes here assert.isTrue(false); // intentionally have Chai throw an assertion error }); runner.runTests(); */console.log("");; console.log("**************************************"); console.log("* running tests *"); console.log("**************************************");
Clear
{{ padName }}