From 7c810b9b5a70b6303493526437ad742afda225cf Mon Sep 17 00:00:00 2001 From: wswebcreation Date: Tue, 3 Jul 2018 16:29:40 +0200 Subject: [PATCH 1/2] feat: add extra info - add feature description - add Given, When, Then keywords - add datatables --- lib/reporter.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index 3526fbc..37191a2 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -35,7 +35,9 @@ class CucumberReporter { title: this.getTitle(feature), type: 'suite', file: uri, - tags: feature.tags + tags: feature.tags, + description: feature.description, + keyword: feature.keyword }) } @@ -86,6 +88,7 @@ class CucumberReporter { } let error = {} let stepTitle = step.text || step.keyword || 'Undefined Step' + let dataTable = [] /** * if step name is undefined we are dealing with a hook @@ -139,6 +142,12 @@ class CucumberReporter { } } + if (step.argument && step.argument.hasOwnProperty('rows')) { + dataTable = [{ + rows: step.argument.rows.map(row => ({cells: row.cells.map(cell => cell.value)})) + }] + } + this.emit('test:' + e, { uid: this.getUniqueIdentifier(step), title: stepTitle.trim(), @@ -147,7 +156,9 @@ class CucumberReporter { parent: this.getUniqueIdentifier(scenario), error: error, duration: new Date() - this.testStart, - tags: scenario.tags + tags: scenario.tags, + keyword: step.keyword, + argument: dataTable }) } @@ -192,7 +203,10 @@ class CucumberReporter { specs: this.specs, tags: payload.tags || [], featureName: payload.featureName, - scenarioName: payload.scenarioName + scenarioName: payload.scenarioName, + description: payload.description, + keyword: payload.keyword || null, + argument: payload.argument } this.send(message, null, {}, () => ++this.receivedMessages) From 03f7de7dea3c316042a8a17b69d7bb2cd80170df Mon Sep 17 00:00:00 2001 From: wswebcreation Date: Wed, 4 Jul 2018 20:20:19 +0200 Subject: [PATCH 2/2] test: update gerkin data for UT --- test/reporter.spec.js | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/test/reporter.spec.js b/test/reporter.spec.js index 48e37f7..2d9a9b8 100644 --- a/test/reporter.spec.js +++ b/test/reporter.spec.js @@ -19,6 +19,7 @@ const gherkinDocEvent = { location: { line: 123, column: 1 }, keyword: 'Feature', name: 'feature', + description: ' This is a feature description\n Second description', children: [{ type: 'Background', location: { line: 124, column: 0 }, @@ -40,13 +41,54 @@ const gherkinDocEvent = { location: { line: 126, column: 0 }, keyword: 'Scenario', name: 'scenario', + description: ' This should be a scenario description', steps: [ { - location: { line: 127, column: 1 }, + type: 'Step', + location: {line: 127, column: 1}, keyword: 'Given ', - text: 'step-title-passing' + text: 'step-title-passing', + argument: { + type: 'DataTable', + location: { line: 15, column: 13 }, + rows: [ + { + type: 'TableRow', + location: { line: 15, column: 13 }, + cells: [ + { + type: 'TableCell', + location: { line: 15, column: 15 }, + value: 'Cucumber' + }, + { + type: 'TableCell', + location: { line: 15, column: 30 }, + value: 'Cucumis sativus' + } + ] + }, + { + type: 'TableRow', + location: { line: 16, column: 13 }, + cells: [ + { + type: 'TableCell', + location: { line: 16, column: 15 }, + value: 'Burr Gherkin' + }, + { + type: 'TableCell', + location: { line: 16, column: 30 }, + value: 'Cucumis anguria' + } + ] + } + ] + } }, { + type: 'Step', location: { line: 128, column: 1 }, keyword: 'When ', text: 'step-title-failing'