-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathworld_in_hooks.feature
68 lines (64 loc) · 1.83 KB
/
world_in_hooks.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
Feature: World in Hooks
Background:
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a step
"""
And a file named "features/step_definitions/cucumber_steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given(/^a step$/, function() {})
"""
And a file named "features/support/world.js" with:
"""
const {setWorldConstructor} = require('@cucumber/cucumber')
function WorldConstructor() {
return {
isWorld: function() { return true }
}
}
setWorldConstructor(WorldConstructor)
"""
Scenario: World is this in hooks
Given a file named "features/support/hooks.js" with:
"""
const {After, Before } = require('@cucumber/cucumber')
Before(function() {
if (!this.isWorld()) {
throw Error("Expected this to be world")
}
})
After(function() {
if (!this.isWorld()) {
throw Error("Expected this to be world")
}
})
"""
When I run cucumber-js
Then it passes
Scenario: World is this in BeforeStep hooks
Given a file named "features/support/hooks.js" with:
"""
const {BeforeStep } = require('@cucumber/cucumber')
BeforeStep(function() {
if (!this.isWorld()) {
throw Error("Expected this to be world")
}
})
"""
When I run cucumber-js
Then it passes
Scenario: World is this in AfterStep hooks
Given a file named "features/support/hooks.js" with:
"""
const {AfterStep } = require('@cucumber/cucumber')
AfterStep(function() {
if (!this.isWorld()) {
throw Error("Expected this to be world")
}
})
"""
When I run cucumber-js
Then it passes