Skip to content

Commit 9ea6b03

Browse files
committed
Print attachment step text on error format
1 parent df5843d commit 9ea6b03

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

features/error_formatting.feature

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Feature: Error formatting
5454
"""
5555
import {Given} from 'cucumber'
5656
57-
Given(/^a basic step$/, function() {})
57+
Given(/^a basic step$/, function() { this.attach('Basic info.') })
5858
Given(/^a step with a doc string$/, function(str) {})
5959
Given(/^a pending step$/, function() { return 'pending' })
6060
"""
@@ -65,6 +65,7 @@ Feature: Error formatting
6565
6666
1) Scenario: some scenario # features/a.feature:3
6767
✔ Given a basic step # features/step_definitions/cucumber_steps.js:3
68+
ℹ Basic info.
6869
✔ And a step with a doc string # features/step_definitions/cucumber_steps.js:4
6970
\"\"\"
7071
my doc string

src/formatter/helpers/issue_helpers.js

+13
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,21 @@ function formatStep({
9191
if (actionLocation) {
9292
text += ` # ${colorFns.location(formatLocation(actionLocation))}`
9393
}
94+
9495
text += '\n'
9596

97+
if (Array.isArray(testStep.attachments)) {
98+
testStep.attachments
99+
.filter(({ media }) => media.type === 'text/plain')
100+
.forEach(({ data }) => {
101+
text +=
102+
indentString(
103+
colorFns[Status.UNDEFINED](figures.info + ' ' + data),
104+
4
105+
) + '\n'
106+
})
107+
}
108+
96109
if (pickleStep) {
97110
let str
98111
const iterator = buildStepArgumentIterator({

0 commit comments

Comments
 (0)