From b9d788355b488de755c2cc5f45df8e7bd60e3731 Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Mon, 4 Dec 2017 12:48:26 +0200 Subject: [PATCH 1/3] use fullTitle of a suite in reporter --- lib/reporter.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index 5f1198d..1b8a1d6 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -15,20 +15,33 @@ class JunitReporter extends events.EventEmitter { super() this.baseReporter = baseReporter + this.suitTitles = {} this.config = config this.options = options this.suiteNameRegEx = this.options.suiteNameFormat instanceof RegExp ? this.options.suiteNameFormat : /[^a-z0-9]+/ + this.on('runner:start', function (runner) { + this.suitTitles[runner.cid] = {} + }) + + this.on('suite:start', function (suite) { + this.suitTitles[suite.cid][suite.uid] = suite.fullTitle; + }) + this.on('end', ::this.onEnd) } + title (cid, uid) { + return this.suitTitles[cid][uid]; + } + onEnd () { const { epilogue } = this.baseReporter for (let cid of Object.keys(this.baseReporter.stats.runners)) { const capabilities = this.baseReporter.stats.runners[cid] - const xml = this.prepareXml(capabilities) + const xml = this.prepareXml(capabilities, cid) this.write(capabilities, cid, xml) } epilogue.call(this.baseReporter) @@ -40,7 +53,7 @@ class JunitReporter extends events.EventEmitter { ).join('_') } - prepareXml (capabilities) { + prepareXml (capabilities, cid) { const builder = junit.newBuilder() const packageName = this.options.packageName ? `${capabilities.sanitizedCapabilities}-${this.options.packageName}` @@ -59,13 +72,14 @@ class JunitReporter extends events.EventEmitter { } const suite = spec.suites[suiteKey] - const suiteName = this.prepareName(suite.title) + const title = this.fullTitle(cid, suite.uid); + const suiteName = this.prepareName(title) const testSuite = builder.testSuite() .name(suiteName) .timestamp(suite.start) .time(suite.duration / 1000) .property('specId', specId) - .property('suiteName', suite.title) + .property('suiteName', title) .property('capabilities', capabilities.sanitizedCapabilities) .property('file', spec.files[0].replace(process.cwd(), '.')) From 8cf858c11d0f3be6e8e639f8dea2675d25d0a362 Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Mon, 4 Dec 2017 13:00:28 +0200 Subject: [PATCH 2/3] fix eslint errors --- lib/reporter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index 1b8a1d6..80865cd 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -27,14 +27,14 @@ class JunitReporter extends events.EventEmitter { }) this.on('suite:start', function (suite) { - this.suitTitles[suite.cid][suite.uid] = suite.fullTitle; + this.suitTitles[suite.cid][suite.uid] = suite.fullTitle }) this.on('end', ::this.onEnd) } title (cid, uid) { - return this.suitTitles[cid][uid]; + return this.suitTitles[cid][uid] } onEnd () { @@ -72,7 +72,7 @@ class JunitReporter extends events.EventEmitter { } const suite = spec.suites[suiteKey] - const title = this.fullTitle(cid, suite.uid); + const title = this.fullTitle(cid, suite.uid) const suiteName = this.prepareName(title) const testSuite = builder.testSuite() .name(suiteName) From e15b861c1979f8d905cd9e725869882ad69d4d37 Mon Sep 17 00:00:00 2001 From: sherlock1982 Date: Mon, 4 Dec 2017 16:09:48 +0200 Subject: [PATCH 3/3] use properly named function --- lib/reporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporter.js b/lib/reporter.js index 80865cd..59cea5a 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -72,7 +72,7 @@ class JunitReporter extends events.EventEmitter { } const suite = spec.suites[suiteKey] - const title = this.fullTitle(cid, suite.uid) + const title = this.title(cid, suite.uid) const suiteName = this.prepareName(title) const testSuite = builder.testSuite() .name(suiteName)