-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathstep_definition_timeouts.feature
111 lines (92 loc) · 2.84 KB
/
step_definition_timeouts.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
Feature: Step definition timeouts
Background:
Given a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given, setDefaultTimeout} = require('@cucumber/cucumber')
setDefaultTimeout(500)
Given(/^a callback step runs slowly$/, function(callback) {
setTimeout(callback, 1000)
})
Given(/^a callback step runs slowly with an increased timeout$/, {timeout: 1500}, function(callback) {
setTimeout(callback, 1000)
})
Given(/^a callback step with a disabled timeout$/, {timeout: -1}, function(callback) {
setTimeout(callback, 1000)
})
Given(/^a promise step runs slowly$/, function() {
return new Promise(resolve => {
setTimeout(resolve, 1000)
})
})
Given(/^a promise step runs slowly with an increased timeout$/, {timeout: 1500}, function() {
return new Promise(resolve => {
setTimeout(resolve, 1000)
})
})
Given(/^a promise step with a disabled timeout$/, {timeout: -1}, function() {
return new Promise(resolve => {
setTimeout(resolve, 1000)
})
})
"""
Scenario Outline: slow steps timeout
Given a file named "features/a.feature" with:
"""
Feature:
Scenario:
When a <TYPE> step runs slowly
"""
When I run cucumber-js
Then it fails
And the output contains the text:
"""
function timed out, ensure the <TYPE> <ASSERT> within 500 milliseconds
"""
Examples:
| TYPE | ASSERT |
| callback | is executed |
| promise | resolves |
Scenario Outline: slow steps can increase their timeout
Given a file named "features/a.feature" with:
"""
Feature:
Scenario:
When a <TYPE> step runs slowly with an increased timeout
"""
When I run cucumber-js
Then it passes
Examples:
| TYPE |
| callback |
| promise |
Scenario Outline: changing step timeouts does not effect other steps
Given a file named "features/a.feature" with:
"""
Feature:
Scenario:
When a <TYPE> step runs slowly with an increased timeout
And a <TYPE> step runs slowly
"""
When I run cucumber-js
Then it fails
And the output contains the text:
"""
function timed out, ensure the <TYPE> <ASSERT> within 500 milliseconds
"""
Examples:
| TYPE | ASSERT |
| callback | is executed |
| promise | resolves |
Scenario Outline: steps can disable timeouts
Given a file named "features/a.feature" with:
"""
Feature:
Scenario:
When a <TYPE> step with a disabled timeout
"""
When I run cucumber-js
Then it passes
Examples:
| TYPE |
| callback |
| promise |