-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
named_hooks.feature
35 lines (31 loc) · 987 Bytes
/
named_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
Feature: Named hooks
As a developer
I want to name a `Before` or `After` hook
So that I can easily identify which hooks are run when reporting
Scenario: Hook is named and then referenced by its name in formatter output
Given a file named "features/a.feature" with:
"""
Feature: some feature
Scenario: some scenario
Given a step
"""
And a file named "features/step_definitions/hooks.js" with:
"""
const {After, Before} = require('@cucumber/cucumber')
Before({name: 'hook 1'}, function() {})
Before({name: 'hook 2'}, function() {})
After({name: 'hook 3'}, function() {})
"""
And a file named "features/step_definitions/steps.js" with:
"""
const {Given} = require('@cucumber/cucumber')
Given('a step', function() {
throw 'nope'
})
"""
When I run cucumber-js
Then it fails
And the output contains the text:
"""
Before (hook 2) #
"""