-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathmultiple_hooks.feature
54 lines (46 loc) · 1.33 KB
/
multiple_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
Feature: Multiple Hooks
Scenario: before hooks run in the order of definition, after hooks in reverse order of definition
Given a file named "features/a.feature" with:
"""
@foo
Feature:
Scenario:
Given a step
Scenario:
Given a step
"""
And a file named "features/step_definitions/world.js" with:
"""
const {setWorldConstructor} = require('@cucumber/cucumber')
setWorldConstructor(function() {
this.value = 0
})
"""
And a file named "features/step_definitions/my_steps.js" with:
"""
const assert = require('assert')
const {Given} = require('@cucumber/cucumber')
Given('a step', function() {})
"""
And a file named "features/step_definitions/hooks.js" with:
"""
const {After, Before} = require('@cucumber/cucumber')
const assert = require('assert')
Before(function() {
assert.equal(this.value, 0)
this.value += 1
})
After(function() {
assert.equal(this.value, 3)
})
Before({tags: '@foo'}, function() {
assert.equal(this.value, 1)
this.value += 1
})
After({tags: '@foo'}, function() {
assert.equal(this.value, 2)
this.value += 1
})
"""
When I run cucumber-js
Then it passes