Skip to content

Commit f4734ef

Browse files
committed
feat(testrunner): show workerId in verbose mode
1 parent d71c9e0 commit f4734ef

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

utils/testrunner/Reporter.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
const RED_COLOR = '\x1b[31m';
1818
const GREEN_COLOR = '\x1b[32m';
19+
const GRAY_COLOR = '\x1b[90m';
1920
const YELLOW_COLOR = '\x1b[33m';
2021
const MAGENTA_COLOR = '\x1b[35m';
2122
const RESET_COLOR = '\x1b[0m';
@@ -202,16 +203,19 @@ class Reporter {
202203
this._workersState.set(workerId, {test, isRunning: false});
203204
if (this._verbose) {
204205
++this._testCounter;
206+
let prefix = `${this._testCounter})`;
207+
if (this._runner.parallel() > 1)
208+
prefix += ` ${GRAY_COLOR}[worker = ${workerId}]${RESET_COLOR}`;
205209
if (test.result === 'ok') {
206-
console.log(`${this._testCounter}) ${GREEN_COLOR}[ OK ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
210+
console.log(`${prefix} ${GREEN_COLOR}[ OK ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
207211
} else if (test.result === 'terminated') {
208-
console.log(`${this._testCounter}) ${MAGENTA_COLOR}[ TERMINATED ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
212+
console.log(`${prefix} ${MAGENTA_COLOR}[ TERMINATED ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
209213
} else if (test.result === 'crashed') {
210-
console.log(`${this._testCounter}) ${RED_COLOR}[ CRASHED ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
214+
console.log(`${prefix} ${RED_COLOR}[ CRASHED ]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
211215
} else if (test.result === 'skipped') {
212-
console.log(`${this._testCounter}) ${YELLOW_COLOR}[SKIP]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
216+
console.log(`${prefix} ${YELLOW_COLOR}[SKIP]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
213217
} else if (test.result === 'failed') {
214-
console.log(`${this._testCounter}) ${RED_COLOR}[FAIL]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
218+
console.log(`${prefix} ${RED_COLOR}[FAIL]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
215219
console.log(' Message:');
216220
console.log(` ${RED_COLOR}${test.error.message || test.error}${RESET_COLOR}`);
217221
console.log(' Stack:');
@@ -222,7 +226,7 @@ class Reporter {
222226
console.log(test.output.split('\n').map(line => ' ' + line).join('\n'));
223227
}
224228
} else if (test.result === 'timedout') {
225-
console.log(`${this._testCounter}) ${RED_COLOR}[TIME]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
229+
console.log(`${prefix} ${RED_COLOR}[TIME]${RESET_COLOR} ${test.fullName} (${formatTestLocation(test)})`);
226230
console.log(' Message:');
227231
console.log(` ${RED_COLOR}Timeout Exceeded ${this._runner.timeout()}ms${RESET_COLOR}`);
228232
}

0 commit comments

Comments
 (0)