mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: teach test reporter to highlight test stackframe on failures. (#1930)
This patch teaches reporter to highlight test stack frame on test failures.
This commit is contained in:
parent
4886d038d5
commit
bae44a82d8
@ -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}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user