From 292ef0ba2925aaff3b02421547921b8a32d45201 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 3 Jan 2018 12:46:43 -0800 Subject: [PATCH 1/4] revert json formatter mime type --- src/formatter/json_formatter.js | 50 ++++------------------------ src/formatter/json_formatter_spec.js | 4 +-- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/src/formatter/json_formatter.js b/src/formatter/json_formatter.js index ec8f348ab..e1582e5cf 100644 --- a/src/formatter/json_formatter.js +++ b/src/formatter/json_formatter.js @@ -161,7 +161,12 @@ export default class JsonFormatter extends Formatter { } } if (_.size(testStep.attachments) > 0) { - data.embeddings = testStep.attachments + data.embeddings = testStep.attachments.map(attachment => { + return { + data: attachment.data, + mime_type: attachment.media.type + } + }) } return data } @@ -171,47 +176,4 @@ export default class JsonFormatter extends Formatter { return { name: tagData.name, line: tagData.location.line } }) } - - handleStepResult(stepResult) { - const step = stepResult.step - const status = stepResult.status - - const currentStep = { - arguments: this.formatStepArguments(step.arguments), - keyword: step.keyword, - name: step.name, - result: { status } - } - - if (step.isBackground) { - currentStep.isBackground = true - } - - if (step.constructor.name === 'Hook') { - currentStep.hidden = true - } else { - currentStep.line = step.line - } - - if (status === Status.PASSED || status === Status.FAILED) { - currentStep.result.duration = stepResult.duration - } - - if (_.size(stepResult.attachments) > 0) { - currentStep.embeddings = this.formatAttachments(stepResult.attachments) - } - - if (status === Status.FAILED && stepResult.failureException) { - currentStep.result.error_message = - stepResult.failureException.stack || stepResult.failureException - } - - if (stepResult.stepDefinition) { - const location = - stepResult.stepDefinition.uri + ':' + stepResult.stepDefinition.line - currentStep.match = { location } - } - - this.currentScenario.steps.push(currentStep) - } } diff --git a/src/formatter/json_formatter_spec.js b/src/formatter/json_formatter_spec.js index 175c941c3..2f7cd06f0 100644 --- a/src/formatter/json_formatter_spec.js +++ b/src/formatter/json_formatter_spec.js @@ -253,8 +253,8 @@ describe('JsonFormatter', function() { it('outputs the step with embeddings', function() { const features = JSON.parse(this.output) expect(features[0].elements[0].steps[0].embeddings).to.eql([ - { data: 'first data', media: { type: 'first media type' } }, - { data: 'second data', media: { type: 'second media type' } } + { data: 'first data', mime_type: 'first media type' }, + { data: 'second data', mime_type: 'second media type' } ]) }) }) From ce9a2ea877a579c11b3175c26f1c38cfb8494d43 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 3 Jan 2018 13:31:55 -0800 Subject: [PATCH 2/4] update --- features/attachments.feature | 18 +++++++++--------- features/step_definitions/json_output_steps.js | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/features/attachments.feature b/features/attachments.feature index 076beb424..c8cd6b9cc 100644 --- a/features/attachments.feature +++ b/features/attachments.feature @@ -29,8 +29,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MEDIA ENCODING | MEDIA TYPE | - | iVBORw== | base64 | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach a stream (callback) Given a file named "features/support/hooks.js" with: @@ -50,8 +50,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MEDIA ENCODING | MEDIA TYPE | - | iVBORw== | base64 | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach a stream (promise) Given a file named "features/support/hooks.js" with: @@ -72,8 +72,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MEDIA ENCODING | MEDIA TYPE | - | iVBORw== | base64 | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach from a before hook Given a file named "features/support/hooks.js" with: @@ -88,7 +88,7 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MEDIA TYPE | + | DATA | MIME TYPE | | text | text/plain | Scenario: Attach from an after hook @@ -104,7 +104,7 @@ Feature: Attachments """ When I run cucumber.js Then the "After" hook has the attachment - | DATA | MEDIA TYPE | + | DATA | MIME TYPE | | text | text/plain | Scenario: Attach from a step definition @@ -120,5 +120,5 @@ Feature: Attachments """ When I run cucumber.js Then the step "a step" has the attachment - | DATA | MEDIA TYPE | + | DATA | MIME TYPE | | text | text/plain | diff --git a/features/step_definitions/json_output_steps.js b/features/step_definitions/json_output_steps.js index 6dd80c593..cc24e45f1 100644 --- a/features/step_definitions/json_output_steps.js +++ b/features/step_definitions/json_output_steps.js @@ -89,7 +89,7 @@ defineSupportCode(({ Then }) => { const tableRowData = table.hashes()[0] const expectedAttachment = { data: tableRowData.DATA, - media: { type: tableRowData['MEDIA TYPE'] } + mime_type: tableRowData['MIME TYPE'] } if (tableRowData['MEDIA ENCODING']) { expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING'] @@ -105,7 +105,7 @@ defineSupportCode(({ Then }) => { const tableRowData = table.hashes()[0] const expectedAttachment = { data: tableRowData.DATA, - media: { type: tableRowData['MEDIA TYPE'] } + mime_type: tableRowData['MIME TYPE'] } if (tableRowData['MEDIA ENCODING']) { expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING'] From 05b72d947f11d81ab12419fe1134af87d5c1b1d1 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 3 Jan 2018 13:34:18 -0800 Subject: [PATCH 3/4] cleanup --- features/step_definitions/json_output_steps.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/features/step_definitions/json_output_steps.js b/features/step_definitions/json_output_steps.js index cc24e45f1..e6b2ca40e 100644 --- a/features/step_definitions/json_output_steps.js +++ b/features/step_definitions/json_output_steps.js @@ -91,9 +91,6 @@ defineSupportCode(({ Then }) => { data: tableRowData.DATA, mime_type: tableRowData['MIME TYPE'] } - if (tableRowData['MEDIA ENCODING']) { - expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING'] - } expect(step.embeddings[0]).to.eql(expectedAttachment) }) @@ -107,9 +104,6 @@ defineSupportCode(({ Then }) => { data: tableRowData.DATA, mime_type: tableRowData['MIME TYPE'] } - if (tableRowData['MEDIA ENCODING']) { - expectedAttachment.media.encoding = tableRowData['MEDIA ENCODING'] - } expect(hook.embeddings[0]).to.eql(expectedAttachment) }) From 7cad068e8a520e228c1f949f48108e955d94dbe1 Mon Sep 17 00:00:00 2001 From: Charles Rudolph Date: Wed, 3 Jan 2018 14:23:32 -0800 Subject: [PATCH 4/4] whitespace --- features/attachments.feature | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/features/attachments.feature b/features/attachments.feature index c8cd6b9cc..a2adc1a35 100644 --- a/features/attachments.feature +++ b/features/attachments.feature @@ -29,8 +29,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MIME TYPE | - | iVBORw== | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach a stream (callback) Given a file named "features/support/hooks.js" with: @@ -50,8 +50,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MIME TYPE | - | iVBORw== | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach a stream (promise) Given a file named "features/support/hooks.js" with: @@ -72,8 +72,8 @@ Feature: Attachments """ When I run cucumber.js Then the "Before" hook has the attachment - | DATA | MIME TYPE | - | iVBORw== | image/png | + | DATA | MIME TYPE | + | iVBORw== | image/png | Scenario: Attach from a before hook Given a file named "features/support/hooks.js" with: