Skip to content
Permalink
Browse files

test: teach test reporter to highlight test stackframe on failures. (#…

…1930)

This patch teaches reporter to highlight test stack frame on
test failures.
  • Loading branch information...
aslushnikov committed Jan 30, 2018
1 parent 4886d03 commit bae44a82d8de82b7535fb5bc5eb4836ffd68d164
Showing with 17 additions and 6 deletions.
  1. +17 −6 utils/testrunner/Reporter.js
@@ -61,16 +61,27 @@ class Reporter {
console.log('\nFailures:');
for (let i = 0; i < failedTests.length; ++i) {
const test = failedTests[i];
console.log(`${i + 1}) ${test.fullName}`);
console.log(`${i + 1}) ${test.fullName} (${formatLocation(test)})`);
if (test.result === 'timedout') {
console.log(' Message:');
console.log(` ${YELLOW_COLOR}Timeout Exceeded ${this._runner.timeout()}ms${RESET_COLOR} ${formatLocation(test)}`);
console.log(` ${YELLOW_COLOR}Timeout Exceeded ${this._runner.timeout()}ms${RESET_COLOR}`);
} else {
console.log(' Message:');
console.log(` ${RED_COLOR}${test.error.message || test.error}${RESET_COLOR} ${formatLocation(test)}`);
console.log(` ${RED_COLOR}${test.error.message || test.error}${RESET_COLOR}`);
console.log(' Stack:');
if (test.error.stack)
console.log(test.error.stack.split('\n').map(line => ' ' + line).join('\n'));
if (test.error.stack) {
const stack = test.error.stack.split('\n').map(line => ' ' + line);
let i = 0;
while (i < stack.length && !stack[i].includes(__dirname))
++i;
while (i < stack.length && stack[i].includes(__dirname))
++i;
if (i < stack.length) {
const indent = stack[i].match(/^\s*/)[0];
stack[i] = stack[i].substring(0, indent.length - 3) + YELLOW_COLOR + '' + RESET_COLOR + stack[i].substring(indent.length - 1);
}
console.log(stack.join('\n'));
}
}
console.log('');
}
@@ -97,7 +108,7 @@ class Reporter {
const location = test.location;
if (!location)
return '';
return `@ ${location.fileName}:${location.lineNumber}:${location.columnNumber}`;
return `${location.fileName}:${location.lineNumber}:${location.columnNumber}`;
}
}

0 comments on commit bae44a8

Please sign in to comment.
You can’t perform that action at this time.