From 5816ec53f74f7d6aadc7aa68fdccfa644f1bd4c3 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 16 Mar 2020 09:04:55 -0700 Subject: [PATCH] fix(testrunner): dedup focused tests and suites by id (#1393) --- utils/testrunner/Reporter.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/utils/testrunner/Reporter.js b/utils/testrunner/Reporter.js index f74dd597b6..79f02698a8 100644 --- a/utils/testrunner/Reporter.js +++ b/utils/testrunner/Reporter.js @@ -48,14 +48,25 @@ class Reporter { } else { console.log(`Running ${colors.yellow(runnableTests.length)} focused tests out of total ${colors.yellow(allTests.length)} on ${colors.yellow(this._runner.parallel())} worker${this._runner.parallel() > 1 ? 's' : ''}`); console.log(''); - const focusedSuites = this._runner.focusedSuites(); - const focusedTests = this._runner.focusedTests(); - if (focusedSuites.length || focusedTests.length) { + const focusedSuites = this._runner.focusedSuites().map(suite => ({ + id: suite.location.filePath + ':' + suite.location.lineNumber + ':' + suite.location.columnNumber, + fullName: suite.fullName, + location: suite.location, + })); + const focusedTests = this._runner.focusedTests().map(test => ({ + id: test.location.filePath + ':' + test.location.lineNumber + ':' + test.location.columnNumber, + fullName: test.fullName, + location: test.location, + })); + const focusedEntities = new Map([ + ...focusedSuites.map(suite => ([suite.id, suite])), + ...focusedTests.map(test => ([test.id, test])), + ]); + if (focusedEntities.size) { console.log('Focused Suites and Tests:'); - for (let i = 0; i < focusedSuites.length; ++i) - console.log(` ${i + 1}) ${focusedSuites[i].fullName} (${formatLocation(focusedSuites[i].location)})`); - for (let i = 0; i < focusedTests.length; ++i) - console.log(` ${i + 1 + focusedSuites.length}) ${focusedTests[i].fullName} (${formatLocation(focusedTests[i].location)})`); + const entities = [...focusedEntities.values()]; + for (let i = 0; i < entities.length; ++i) + console.log(` ${i + 1}) ${entities[i].fullName} (${formatLocation(entities[i].location)})`); console.log(''); } }