Browse Source

create stackTraceLine helper to debug predicates

pull/946/head
Lily He 7 years ago
parent
commit
7ecf770d79
  1. 13
      helper/stackTraceLine.js
  2. 20
      test/unit/helper/stackTraceLine.js
  3. 1
      test/unit/run.js

13
helper/stackTraceLine.js

@ -0,0 +1,13 @@
'use strict';
module.exports = () => {
const stack = new Error().stack.split('\n');
let targetLine;
stack.forEach((line) => {
if(line.indexOf('at controller') !== -1) {
targetLine = line.trim();
}
});
return targetLine;
};

20
test/unit/helper/stackTraceLine.js

@ -0,0 +1,20 @@
const stackTraceLine = require('../../../helper/stackTraceLine');
module.exports.tests = {};
module.exports.tests.stackTrace = (test, common) => {
test('No exceptions thrown when function is called', (t) => {
t.doesNotThrow(stackTraceLine, 'No exceptions thrown');
t.end();
});
};
module.exports.all = function (tape, common) {
function test(name, testFunction) {
return tape('[helper] stackTraceLine: ' + name, testFunction);
}
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};

1
test/unit/run.js

@ -35,6 +35,7 @@ var tests = [
require('./helper/logging'),
require('./helper/type_mapping'),
require('./helper/sizeCalculator'),
require('./helper/stackTraceLine'),
require('./middleware/access_log'),
require('./middleware/accuracy'),
require('./middleware/assignLabels'),

Loading…
Cancel
Save