forked from cucumber/cucumber-js
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstep_definition_snippets_custom_syntax.feature
70 lines (60 loc) · 2.5 KB
/
step_definition_snippets_custom_syntax.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
Feature: step definition snippets custom syntax
As a developer writing my step definitions in another JS dialect
I want to be able to see step definition snippets in the language I perfer
Background:
Given a file named "features/undefined.feature" with:
"""
Feature: a feature
Scenario: a scenario
Given an undefined step
"""
And a file named "coffeescript_syntax.js" with:
"""
function CoffeeScriptSyntax(interface) {
return {
build: function build (functionName, pattern, parameters, comment) {
var implementation;
if (interface === 'callback') {
var callbackName = parameters[parameters.length - 1];
implementation = callbackName + ' null, \'pending\'';
} else {
parameters.pop();
implementation = '\'pending\'';
}
var callbackName = parameters[parameters.length - 1];
var parametersStr = parameters.length > 0 ? '(' + parameters.join(', ') + ') ' : '';
var snippet =
'@' + functionName + ' ' + pattern + ', ' + parametersStr + '-> ' + '\n' +
' # ' + comment + '\n' +
' ' + implementation;
return snippet;
}
};
}
module.exports = CoffeeScriptSyntax;
"""
Scenario Outline:
When I run cucumber-js with `--snippet-interface <INTERFACE> --snippet-syntax coffeescript_syntax.js`
Then it outputs this text:
"""
Feature: a feature
Scenario: a scenario
? Given an undefined step
Warnings:
1) Scenario: a scenario - features/undefined.feature:2
Step: Given an undefined step - features/undefined.feature:3
Message:
Undefined. Implement with the following snippet:
@Given /^an undefined step$/, <SNIPPET_PARAMETERS_AND_ARROW>
# Write code here that turns the phrase above into concrete actions
<SNIPPET_IMPLEMENTATION>
1 scenario (1 undefined)
1 step (1 undefined)
<duration-stat>
"""
Examples:
| INTERFACE | SNIPPET_PARAMETERS_AND_ARROW | SNIPPET_IMPLEMENTATION |
| callback | (callback) -> | callback null, 'pending' |
| generator | -> | 'pending' |
| promise | -> | 'pending' |
| synchronous | -> | 'pending' |