File tree 3 files changed +22
-20
lines changed
3 files changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ Feature: Error formatting
54
54
"""
55
55
import {Given} from 'cucumber'
56
56
57
- Given(/^a basic step$/, function() { this.attach('Basic info.') })
58
- Given(/^a step with a doc string$/, function(str) {})
57
+ Given(/^a basic step$/, function() { this.attach('Some info.') })
58
+ Given(/^a step with a doc string$/, function(str) { this.attach('Other info.') })
59
59
Given(/^a pending step$/, function() { return 'pending' })
60
60
"""
61
61
When I run cucumber-js
@@ -65,11 +65,12 @@ Feature: Error formatting
65
65
66
66
1) Scenario: some scenario # features/a.feature:3
67
67
✔ Given a basic step # features/step_definitions/cucumber_steps.js:3
68
- Attachment (text/plain): Basic info.
68
+ Attachment (text/plain): Some info.
69
69
✔ And a step with a doc string # features/step_definitions/cucumber_steps.js:4
70
70
\"\"\"
71
71
my doc string
72
72
\"\"\"
73
+ Attachment (text/plain): Other info.
73
74
? And a pending step # features/step_definitions/cucumber_steps.js:5
74
75
Pending
75
76
"""
Original file line number Diff line number Diff line change @@ -93,14 +93,6 @@ function formatStep({
93
93
}
94
94
text += '\n'
95
95
96
- if ( testStep . attachments ) {
97
- testStep . attachments
98
- . filter ( ( { media } ) => media . type === 'text/plain' )
99
- . forEach ( ( { data } ) => {
100
- text += indentString ( 'Attachment (text/plain): ' + data , 4 ) + '\n'
101
- } )
102
- }
103
-
104
96
if ( pickleStep ) {
105
97
let str
106
98
const iterator = buildStepArgumentIterator ( {
@@ -112,6 +104,14 @@ function formatStep({
112
104
text += indentString ( `${ colorFn ( str ) } \n` , 4 )
113
105
}
114
106
}
107
+
108
+ if ( testStep . attachments ) {
109
+ testStep . attachments . forEach ( ( { media, data } ) => {
110
+ const message = media . type === 'text/plain' ? `: ${ data } ` : ''
111
+ text += indentString ( `Attachment (${ media . type } )${ message } \n` , 4 )
112
+ } )
113
+ }
114
+
115
115
const message = getStepMessage ( {
116
116
colorFns,
117
117
keywordType,
Original file line number Diff line number Diff line change @@ -241,21 +241,21 @@ describe('IssueHelpers', () => {
241
241
this . testCase . steps [ 0 ] . result = this . passedStepResult
242
242
this . testCase . steps [ 0 ] . attachments = [
243
243
{
244
- data : 'First info.' ,
244
+ data : 'Some info.' ,
245
245
media : {
246
246
type : 'text/plain' ,
247
247
} ,
248
248
} ,
249
249
{
250
- data : 'Nop ' ,
250
+ data : '{"name": "some JSON"} ' ,
251
251
media : {
252
- type : 'text/special ' ,
252
+ type : 'application/json ' ,
253
253
} ,
254
254
} ,
255
255
{
256
- data : 'Second info.' ,
256
+ data : Buffer . from ( [ ] ) ,
257
257
media : {
258
- type : 'text/plain ' ,
258
+ type : 'image/png ' ,
259
259
} ,
260
260
} ,
261
261
]
@@ -269,7 +269,7 @@ describe('IssueHelpers', () => {
269
269
}
270
270
this . testCase . steps [ 1 ] . attachments = [
271
271
{
272
- data : 'Third info.' ,
272
+ data : 'Other info.' ,
273
273
media : {
274
274
type : 'text/plain' ,
275
275
} ,
@@ -283,10 +283,11 @@ describe('IssueHelpers', () => {
283
283
expect ( this . formattedIssue ) . to . eql (
284
284
'1) Scenario: my scenario # a.feature:2\n' +
285
285
` ${ figures . tick } Given step1 # steps.js:2\n` +
286
- ` Attachment (text/plain): First info.\n` +
287
- ` Attachment (text/plain): Second info.\n` +
286
+ ` Attachment (text/plain): Some info.\n` +
287
+ ` Attachment (application/json)\n` +
288
+ ` Attachment (image/png)\n` +
288
289
` ${ figures . cross } When step2 # steps.js:3\n` +
289
- ` Attachment (text/plain): Third info.\n` +
290
+ ` Attachment (text/plain): Other info.\n` +
290
291
' error\n' +
291
292
' - Then step3 # steps.js:4\n\n'
292
293
)
You can’t perform that action at this time.
0 commit comments