-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy patherror_formatting.feature
136 lines (119 loc) · 4.29 KB
/
error_formatting.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Feature: Error formatting
Scenario: failing scenario with hook error
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a passing step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a passing step$/, function() {})
"""
And a file named "features/support/hooks.js" with:
"""
const {Before} = require('@cucumber/cucumber')
Before(function(_, callback) { callback('Fail') })
"""
When I run cucumber-js
Then it fails
And it outputs the text:
"""
F-
Failures:
1) Scenario: some scenario # features/a.feature:2
✖ Before # features/support/hooks.js:3
Fail
- Given a passing step # features/step_definitions/cucumber_steps.js:3
1 scenario (1 failed)
1 step (1 skipped)
<duration-stat>
"""
Scenario: failing scenario has step with doc string
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a basic step
And a step with a doc string
\"\"\"
my doc string
\"\"\"
And a pending step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a basic step$/, function() { this.attach('Some info.') })
Given(/^a step with a doc string$/, function(str) { this.attach('{"name": "some JSON"}', 'application/json') })
Given(/^a pending step$/, function() { return 'pending' })
"""
When I run cucumber-js
Then the output contains the text:
"""
Warnings:
1) Scenario: some scenario # features/a.feature:3
✔ Given a basic step # features/step_definitions/cucumber_steps.js:3
Attachment (text/plain): Some info.
✔ And a step with a doc string # features/step_definitions/cucumber_steps.js:4
\"\"\"
my doc string
\"\"\"
Attachment (application/json)
? And a pending step # features/step_definitions/cucumber_steps.js:5
Pending
"""
And it fails
Scenario: failing scenario has step with data table
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a table:
| foo\nbar |bar | baz |
| foo\nbar\n\nbaz\n\\boo |bar | baz\nfoo |
And a pending step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a table:$/, function(table) {})
Given(/^a pending step$/, function() { return 'pending' })
"""
When I run cucumber-js
Then the output contains the text:
"""
Warnings:
1) Scenario: some scenario # features/a.feature:3
✔ Given a table: # features/step_definitions/cucumber_steps.js:3
| foo\nbar | bar | baz |
| foo\nbar\n\nbaz\n\\boo | bar | baz\nfoo |
? And a pending step # features/step_definitions/cucumber_steps.js:4
Pending
"""
And it fails
Scenario: failing scenario when requested to not print step attachments
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a basic step
And a pending step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a basic step$/, function() { this.attach('Some attached text.') })
Given(/^a pending step$/, function() { return 'pending' })
"""
When I run cucumber-js with `--format-options '{"printAttachments": false}'`
Then the output contains the text:
"""
Warnings:
1) Scenario: some scenario # features/a.feature:3
✔ Given a basic step # features/step_definitions/cucumber_steps.js:3
? And a pending step # features/step_definitions/cucumber_steps.js:4
Pending
"""
And it fails