From b01f6d69e2a92c42bede73a3d611d5b577931953 Mon Sep 17 00:00:00 2001 From: Koushik Mohan Date: Tue, 12 May 2020 13:02:01 +0530 Subject: [PATCH 1/2] Add skipped event for workers --- lib/command/run-workers.js | 9 ++++++++- lib/command/workers/runTests.js | 5 +++++ lib/reporter/cli.js | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/command/run-workers.js b/lib/command/run-workers.js index 6abaf6100..3386e377f 100644 --- a/lib/command/run-workers.js +++ b/lib/command/run-workers.js @@ -17,6 +17,7 @@ const stats = { passes: 0, failures: 0, tests: 0, + pending: 0, }; @@ -108,6 +109,10 @@ module.exports = function (workers, options) { output.test.passed(repackTest(message.data)); updateFinishedTests(repackTest(message.data), maxReruns); break; + case event.test.skipped: + output.test.skipped(repackTest(message.data)); + updateFinishedTests(repackTest(message.data), maxReruns); + break; case event.suite.before: output.suite.started(message.data); break; case event.all.after: appendStats(message.data); break; } @@ -136,8 +141,9 @@ function printResults() { stats.end = new Date(); stats.duration = stats.end - stats.start; output.print(); + console.log() if (stats.tests === 0 || (stats.passes && !errors.length)) { - output.result(stats.passes, stats.failures, 0, `${stats.duration / 1000}s`); + output.result(stats.passes, stats.failures, stats.pending, `${stats.duration / 1000}s`); } if (stats.failures) { output.print(); @@ -206,6 +212,7 @@ function appendStats(newStats) { stats.passes += newStats.passes; stats.failures += newStats.failures; stats.tests += newStats.tests; + stats.pending += newStats.pending; } function repackTest(test) { diff --git a/lib/command/workers/runTests.js b/lib/command/workers/runTests.js index f46f3aff0..b1b160e4d 100644 --- a/lib/command/workers/runTests.js +++ b/lib/command/workers/runTests.js @@ -104,6 +104,7 @@ function initializeListeners() { event.dispatcher.on(event.test.failed, test => sendToParentThread({ event: event.test.failed, workerIndex, data: simplifyTest(test) })); event.dispatcher.on(event.test.passed, test => sendToParentThread({ event: event.test.passed, workerIndex, data: simplifyTest(test) })); event.dispatcher.on(event.test.started, test => sendToParentThread({ event: event.test.started, workerIndex, data: simplifyTest(test) })); + event.dispatcher.on(event.test.skipped, test => sendToParentThread({ event: event.test.skipped, workerIndex, data: simplifyTest(test) })); event.dispatcher.on(event.hook.failed, (test, err) => sendToParentThread({ event: event.hook.failed, workerIndex, data: simplifyTest(test, err) })); event.dispatcher.on(event.hook.passed, (test, err) => sendToParentThread({ event: event.hook.passed, workerIndex, data: simplifyTest(test, err) })); @@ -122,6 +123,7 @@ function collectStats() { passes: 0, failures: 0, tests: 0, + pending: 0, }; event.dispatcher.on(event.test.passed, () => { stats.passes++; @@ -129,6 +131,9 @@ function collectStats() { event.dispatcher.on(event.test.failed, () => { stats.failures++; }); + event.dispatcher.on(event.test.skipped, () => { + stats.pending++; + }); event.dispatcher.on(event.test.finished, () => { stats.tests++; }); diff --git a/lib/reporter/cli.js b/lib/reporter/cli.js index 586557dab..0c9636977 100644 --- a/lib/reporter/cli.js +++ b/lib/reporter/cli.js @@ -100,6 +100,9 @@ class Cli extends Base { for (const test of suite.tests) { if (!test.state && !this.loadedTests.includes(test.id)) { if (matchTest(grep, test.title)) { + if (!test.opts) { + test.opts = {}; + } if (!test.opts.skipInfo) { test.opts.skipInfo = {}; } From 0281b047b3c5f26d3b563e6f63de767dbef24a50 Mon Sep 17 00:00:00 2001 From: Koushik Mohan Date: Tue, 12 May 2020 13:50:17 +0530 Subject: [PATCH 2/2] review changes --- lib/command/run-workers.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/command/run-workers.js b/lib/command/run-workers.js index 3386e377f..e80a91380 100644 --- a/lib/command/run-workers.js +++ b/lib/command/run-workers.js @@ -141,7 +141,6 @@ function printResults() { stats.end = new Date(); stats.duration = stats.end - stats.start; output.print(); - console.log() if (stats.tests === 0 || (stats.passes && !errors.length)) { output.result(stats.passes, stats.failures, stats.pending, `${stats.duration / 1000}s`); }