pickle-jar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/pickle-jar.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/Makefile +43 -0
- package/README.md +155 -0
- package/gen/GherkinLexer.interp +82 -0
- package/gen/GherkinLexer.java +313 -0
- package/gen/GherkinLexer.tokens +22 -0
- package/grammar.sh +7 -0
- package/jest.config.js +12 -0
- package/nodemon.json +6 -0
- package/package.json +30 -0
- package/src/feature-file-visitor.ts +154 -0
- package/src/get-call-sites.ts +7 -0
- package/src/grammar/GherkinLexer.g4 +29 -0
- package/src/grammar/GherkinLexer.interp +82 -0
- package/src/grammar/GherkinLexer.tokens +22 -0
- package/src/grammar/GherkinLexer.ts +245 -0
- package/src/grammar/GherkinParser.g4 +45 -0
- package/src/grammar/GherkinParser.interp +73 -0
- package/src/grammar/GherkinParser.tokens +22 -0
- package/src/grammar/GherkinParser.ts +1728 -0
- package/src/grammar/GherkinParserVisitor.ts +176 -0
- package/src/grammar/tsconfig.json +9 -0
- package/src/index.ts +3 -0
- package/src/step-definition.ts +6 -0
- package/src/step.ts +1 -0
- package/src/test-runner.ts +34 -0
- package/test/features/ScenarioOutlines.feature +15 -0
- package/test/features/Scenarios.feature +41 -0
- package/test/runner.ts +90 -0
- package/tsconfig.json +47 -0
- package/tsconfig.spec.json +14 -0
- package/typedoc.json +8 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// Generated from /Users/seba/dev/_personal/pickle-jar/src/grammar/GherkinLexer.g4 by ANTLR 4.12.0
|
|
2
|
+
import org.antlr.v4.runtime.Lexer;
|
|
3
|
+
import org.antlr.v4.runtime.CharStream;
|
|
4
|
+
import org.antlr.v4.runtime.Token;
|
|
5
|
+
import org.antlr.v4.runtime.TokenStream;
|
|
6
|
+
import org.antlr.v4.runtime.*;
|
|
7
|
+
import org.antlr.v4.runtime.atn.*;
|
|
8
|
+
import org.antlr.v4.runtime.dfa.DFA;
|
|
9
|
+
import org.antlr.v4.runtime.misc.*;
|
|
10
|
+
|
|
11
|
+
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
|
|
12
|
+
public class GherkinLexer extends Lexer {
|
|
13
|
+
static { RuntimeMetaData.checkVersion("4.12.0", RuntimeMetaData.VERSION); }
|
|
14
|
+
|
|
15
|
+
protected static final DFA[] _decisionToDFA;
|
|
16
|
+
protected static final PredictionContextCache _sharedContextCache =
|
|
17
|
+
new PredictionContextCache();
|
|
18
|
+
public static final int
|
|
19
|
+
FEATURE=1, SCENARIO=2, SCENARIO_OUTLINE=3, GIVEN=4, AND_GIVEN=5, WHEN=6,
|
|
20
|
+
AND_WHEN=7, THEN=8, AND=9, BUT=10, EXAMPLES=11, BACKGROUND=12, PIPE=13,
|
|
21
|
+
TAG=14, COMMENT=15, TEXT_CHARACTER=16, WS=17, WSS=18, DOC_STRING_QUOT=19,
|
|
22
|
+
DOC_STRING_TEXT=20, DOC_STRING_WS=21;
|
|
23
|
+
public static final int
|
|
24
|
+
DOC_STRING_MODE=1;
|
|
25
|
+
public static String[] channelNames = {
|
|
26
|
+
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
public static String[] modeNames = {
|
|
30
|
+
"DEFAULT_MODE", "DOC_STRING_MODE"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
private static String[] makeRuleNames() {
|
|
34
|
+
return new String[] {
|
|
35
|
+
"FEATURE", "SCENARIO", "SCENARIO_OUTLINE", "GIVEN", "AND_GIVEN", "WHEN",
|
|
36
|
+
"AND_WHEN", "THEN", "AND", "BUT", "EXAMPLES", "BACKGROUND", "PIPE", "TAG",
|
|
37
|
+
"COMMENT", "TEXT_CHARACTER", "WS", "WSS", "DOC_STRING_QUOT", "DOC_STRING_TEXT",
|
|
38
|
+
"DOC_STRING_WS", "DOC_STRING_QUOT_2"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
public static final String[] ruleNames = makeRuleNames();
|
|
42
|
+
|
|
43
|
+
private static String[] makeLiteralNames() {
|
|
44
|
+
return new String[] {
|
|
45
|
+
null, null, null, null, null, null, null, null, null, null, null, null,
|
|
46
|
+
null, "'|'"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
50
|
+
private static String[] makeSymbolicNames() {
|
|
51
|
+
return new String[] {
|
|
52
|
+
null, "FEATURE", "SCENARIO", "SCENARIO_OUTLINE", "GIVEN", "AND_GIVEN",
|
|
53
|
+
"WHEN", "AND_WHEN", "THEN", "AND", "BUT", "EXAMPLES", "BACKGROUND", "PIPE",
|
|
54
|
+
"TAG", "COMMENT", "TEXT_CHARACTER", "WS", "WSS", "DOC_STRING_QUOT", "DOC_STRING_TEXT",
|
|
55
|
+
"DOC_STRING_WS"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
|
59
|
+
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use {@link #VOCABULARY} instead.
|
|
63
|
+
*/
|
|
64
|
+
@Deprecated
|
|
65
|
+
public static final String[] tokenNames;
|
|
66
|
+
static {
|
|
67
|
+
tokenNames = new String[_SYMBOLIC_NAMES.length];
|
|
68
|
+
for (int i = 0; i < tokenNames.length; i++) {
|
|
69
|
+
tokenNames[i] = VOCABULARY.getLiteralName(i);
|
|
70
|
+
if (tokenNames[i] == null) {
|
|
71
|
+
tokenNames[i] = VOCABULARY.getSymbolicName(i);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (tokenNames[i] == null) {
|
|
75
|
+
tokenNames[i] = "<INVALID>";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
@Deprecated
|
|
82
|
+
public String[] getTokenNames() {
|
|
83
|
+
return tokenNames;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Override
|
|
87
|
+
|
|
88
|
+
public Vocabulary getVocabulary() {
|
|
89
|
+
return VOCABULARY;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
public GherkinLexer(CharStream input) {
|
|
94
|
+
super(input);
|
|
95
|
+
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Override
|
|
99
|
+
public String getGrammarFileName() { return "GherkinLexer.g4"; }
|
|
100
|
+
|
|
101
|
+
@Override
|
|
102
|
+
public String[] getRuleNames() { return ruleNames; }
|
|
103
|
+
|
|
104
|
+
@Override
|
|
105
|
+
public String getSerializedATN() { return _serializedATN; }
|
|
106
|
+
|
|
107
|
+
@Override
|
|
108
|
+
public String[] getChannelNames() { return channelNames; }
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
public String[] getModeNames() { return modeNames; }
|
|
112
|
+
|
|
113
|
+
@Override
|
|
114
|
+
public ATN getATN() { return _ATN; }
|
|
115
|
+
|
|
116
|
+
public static final String _serializedATN =
|
|
117
|
+
"\u0004\u0000\u0015\u012d\u0006\uffff\uffff\u0006\uffff\uffff\u0002\u0000"+
|
|
118
|
+
"\u0007\u0000\u0002\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003"+
|
|
119
|
+
"\u0007\u0003\u0002\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006"+
|
|
120
|
+
"\u0007\u0006\u0002\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002"+
|
|
121
|
+
"\n\u0007\n\u0002\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002"+
|
|
122
|
+
"\u000e\u0007\u000e\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002"+
|
|
123
|
+
"\u0011\u0007\u0011\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002"+
|
|
124
|
+
"\u0014\u0007\u0014\u0002\u0015\u0007\u0015\u0001\u0000\u0001\u0000\u0001"+
|
|
125
|
+
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001"+
|
|
126
|
+
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001"+
|
|
127
|
+
"\u0000\u0003\u0000>\b\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
|
128
|
+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
|
129
|
+
"\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
|
130
|
+
"\u0001\u0001\u0001\u0003\u0001Q\b\u0001\u0001\u0002\u0001\u0002\u0001"+
|
|
131
|
+
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
|
132
|
+
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
|
133
|
+
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
|
134
|
+
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
|
135
|
+
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
|
136
|
+
"\u0002\u0003\u0002t\b\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+
|
|
137
|
+
"\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+
|
|
138
|
+
"\u0003\u0003\u0003\u0080\b\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+
|
|
139
|
+
"\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+
|
|
140
|
+
"\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+
|
|
141
|
+
"\u0004\u0001\u0004\u0001\u0004\u0003\u0004\u0094\b\u0004\u0001\u0005\u0001"+
|
|
142
|
+
"\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001"+
|
|
143
|
+
"\u0005\u0003\u0005\u009e\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001"+
|
|
144
|
+
"\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001"+
|
|
145
|
+
"\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001"+
|
|
146
|
+
"\u0006\u0003\u0006\u00b0\b\u0006\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+
|
|
147
|
+
"\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0003\u0007\u00ba"+
|
|
148
|
+
"\b\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0003\b\u00c2"+
|
|
149
|
+
"\b\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\t\u0003\t\u00ca\b\t"+
|
|
150
|
+
"\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+
|
|
151
|
+
"\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0003"+
|
|
152
|
+
"\n\u00dd\b\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+
|
|
153
|
+
"\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+
|
|
154
|
+
"\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+
|
|
155
|
+
"\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0003\u000b\u00f4\b\u000b"+
|
|
156
|
+
"\u0001\f\u0001\f\u0001\r\u0001\r\u0004\r\u00fa\b\r\u000b\r\f\r\u00fb\u0001"+
|
|
157
|
+
"\u000e\u0001\u000e\u0005\u000e\u0100\b\u000e\n\u000e\f\u000e\u0103\t\u000e"+
|
|
158
|
+
"\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u0010\u0004\u0010"+
|
|
159
|
+
"\u010a\b\u0010\u000b\u0010\f\u0010\u010b\u0001\u0010\u0001\u0010\u0001"+
|
|
160
|
+
"\u0011\u0004\u0011\u0111\b\u0011\u000b\u0011\f\u0011\u0112\u0001\u0011"+
|
|
161
|
+
"\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+
|
|
162
|
+
"\u0001\u0012\u0001\u0013\u0004\u0013\u011e\b\u0013\u000b\u0013\f\u0013"+
|
|
163
|
+
"\u011f\u0001\u0014\u0004\u0014\u0123\b\u0014\u000b\u0014\f\u0014\u0124"+
|
|
164
|
+
"\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015"+
|
|
165
|
+
"\u0001\u0015\u0000\u0000\u0016\u0002\u0001\u0004\u0002\u0006\u0003\b\u0004"+
|
|
166
|
+
"\n\u0005\f\u0006\u000e\u0007\u0010\b\u0012\t\u0014\n\u0016\u000b\u0018"+
|
|
167
|
+
"\f\u001a\r\u001c\u000e\u001e\u000f \u0010\"\u0011$\u0012&\u0013(\u0014"+
|
|
168
|
+
"*\u0015,\u0000\u0002\u0000\u0001\u0005\u0004\u000009AZ__az\u0002\u0000"+
|
|
169
|
+
"\n\n\r\r\u0003\u0000\n\n\r\r\"\"\u0003\u0000\t\n\r\r \u0001\u0000\"\""+
|
|
170
|
+
"\u013d\u0000\u0002\u0001\u0000\u0000\u0000\u0000\u0004\u0001\u0000\u0000"+
|
|
171
|
+
"\u0000\u0000\u0006\u0001\u0000\u0000\u0000\u0000\b\u0001\u0000\u0000\u0000"+
|
|
172
|
+
"\u0000\n\u0001\u0000\u0000\u0000\u0000\f\u0001\u0000\u0000\u0000\u0000"+
|
|
173
|
+
"\u000e\u0001\u0000\u0000\u0000\u0000\u0010\u0001\u0000\u0000\u0000\u0000"+
|
|
174
|
+
"\u0012\u0001\u0000\u0000\u0000\u0000\u0014\u0001\u0000\u0000\u0000\u0000"+
|
|
175
|
+
"\u0016\u0001\u0000\u0000\u0000\u0000\u0018\u0001\u0000\u0000\u0000\u0000"+
|
|
176
|
+
"\u001a\u0001\u0000\u0000\u0000\u0000\u001c\u0001\u0000\u0000\u0000\u0000"+
|
|
177
|
+
"\u001e\u0001\u0000\u0000\u0000\u0000 \u0001\u0000\u0000\u0000\u0000\""+
|
|
178
|
+
"\u0001\u0000\u0000\u0000\u0000$\u0001\u0000\u0000\u0000\u0000&\u0001\u0000"+
|
|
179
|
+
"\u0000\u0000\u0001(\u0001\u0000\u0000\u0000\u0001*\u0001\u0000\u0000\u0000"+
|
|
180
|
+
"\u0001,\u0001\u0000\u0000\u0000\u0002=\u0001\u0000\u0000\u0000\u0004P"+
|
|
181
|
+
"\u0001\u0000\u0000\u0000\u0006s\u0001\u0000\u0000\u0000\b\u007f\u0001"+
|
|
182
|
+
"\u0000\u0000\u0000\n\u0093\u0001\u0000\u0000\u0000\f\u009d\u0001\u0000"+
|
|
183
|
+
"\u0000\u0000\u000e\u00af\u0001\u0000\u0000\u0000\u0010\u00b9\u0001\u0000"+
|
|
184
|
+
"\u0000\u0000\u0012\u00c1\u0001\u0000\u0000\u0000\u0014\u00c9\u0001\u0000"+
|
|
185
|
+
"\u0000\u0000\u0016\u00dc\u0001\u0000\u0000\u0000\u0018\u00f3\u0001\u0000"+
|
|
186
|
+
"\u0000\u0000\u001a\u00f5\u0001\u0000\u0000\u0000\u001c\u00f7\u0001\u0000"+
|
|
187
|
+
"\u0000\u0000\u001e\u00fd\u0001\u0000\u0000\u0000 \u0106\u0001\u0000\u0000"+
|
|
188
|
+
"\u0000\"\u0109\u0001\u0000\u0000\u0000$\u0110\u0001\u0000\u0000\u0000"+
|
|
189
|
+
"&\u0116\u0001\u0000\u0000\u0000(\u011d\u0001\u0000\u0000\u0000*\u0122"+
|
|
190
|
+
"\u0001\u0000\u0000\u0000,\u0126\u0001\u0000\u0000\u0000./\u0005F\u0000"+
|
|
191
|
+
"\u0000/0\u0005e\u0000\u000001\u0005a\u0000\u000012\u0005t\u0000\u0000"+
|
|
192
|
+
"23\u0005u\u0000\u000034\u0005r\u0000\u000045\u0005e\u0000\u00005>\u0005"+
|
|
193
|
+
":\u0000\u000067\u0005F\u0000\u000078\u0005E\u0000\u000089\u0005A\u0000"+
|
|
194
|
+
"\u00009:\u0005T\u0000\u0000:;\u0005U\u0000\u0000;<\u0005R\u0000\u0000"+
|
|
195
|
+
"<>\u0005E\u0000\u0000=.\u0001\u0000\u0000\u0000=6\u0001\u0000\u0000\u0000"+
|
|
196
|
+
">\u0003\u0001\u0000\u0000\u0000?@\u0005S\u0000\u0000@A\u0005c\u0000\u0000"+
|
|
197
|
+
"AB\u0005e\u0000\u0000BC\u0005n\u0000\u0000CD\u0005a\u0000\u0000DE\u0005"+
|
|
198
|
+
"r\u0000\u0000EF\u0005i\u0000\u0000FG\u0005o\u0000\u0000GQ\u0005:\u0000"+
|
|
199
|
+
"\u0000HI\u0005S\u0000\u0000IJ\u0005C\u0000\u0000JK\u0005E\u0000\u0000"+
|
|
200
|
+
"KL\u0005N\u0000\u0000LM\u0005A\u0000\u0000MN\u0005R\u0000\u0000NO\u0005"+
|
|
201
|
+
"I\u0000\u0000OQ\u0005O\u0000\u0000P?\u0001\u0000\u0000\u0000PH\u0001\u0000"+
|
|
202
|
+
"\u0000\u0000Q\u0005\u0001\u0000\u0000\u0000RS\u0005S\u0000\u0000ST\u0005"+
|
|
203
|
+
"c\u0000\u0000TU\u0005e\u0000\u0000UV\u0005n\u0000\u0000VW\u0005a\u0000"+
|
|
204
|
+
"\u0000WX\u0005r\u0000\u0000XY\u0005i\u0000\u0000YZ\u0005o\u0000\u0000"+
|
|
205
|
+
"Z[\u0005 \u0000\u0000[\\\u0005O\u0000\u0000\\]\u0005u\u0000\u0000]^\u0005"+
|
|
206
|
+
"t\u0000\u0000^_\u0005l\u0000\u0000_`\u0005i\u0000\u0000`a\u0005n\u0000"+
|
|
207
|
+
"\u0000ab\u0005e\u0000\u0000bt\u0005:\u0000\u0000cd\u0005S\u0000\u0000"+
|
|
208
|
+
"de\u0005C\u0000\u0000ef\u0005E\u0000\u0000fg\u0005N\u0000\u0000gh\u0005"+
|
|
209
|
+
"A\u0000\u0000hi\u0005R\u0000\u0000ij\u0005I\u0000\u0000jk\u0005O\u0000"+
|
|
210
|
+
"\u0000kl\u0005_\u0000\u0000lm\u0005O\u0000\u0000mn\u0005U\u0000\u0000"+
|
|
211
|
+
"no\u0005T\u0000\u0000op\u0005L\u0000\u0000pq\u0005I\u0000\u0000qr\u0005"+
|
|
212
|
+
"N\u0000\u0000rt\u0005E\u0000\u0000sR\u0001\u0000\u0000\u0000sc\u0001\u0000"+
|
|
213
|
+
"\u0000\u0000t\u0007\u0001\u0000\u0000\u0000uv\u0005G\u0000\u0000vw\u0005"+
|
|
214
|
+
"i\u0000\u0000wx\u0005v\u0000\u0000xy\u0005e\u0000\u0000y\u0080\u0005n"+
|
|
215
|
+
"\u0000\u0000z{\u0005G\u0000\u0000{|\u0005I\u0000\u0000|}\u0005V\u0000"+
|
|
216
|
+
"\u0000}~\u0005E\u0000\u0000~\u0080\u0005N\u0000\u0000\u007fu\u0001\u0000"+
|
|
217
|
+
"\u0000\u0000\u007fz\u0001\u0000\u0000\u0000\u0080\t\u0001\u0000\u0000"+
|
|
218
|
+
"\u0000\u0081\u0082\u0005A\u0000\u0000\u0082\u0083\u0005n\u0000\u0000\u0083"+
|
|
219
|
+
"\u0084\u0005d\u0000\u0000\u0084\u0085\u0005 \u0000\u0000\u0085\u0086\u0005"+
|
|
220
|
+
"g\u0000\u0000\u0086\u0087\u0005i\u0000\u0000\u0087\u0088\u0005v\u0000"+
|
|
221
|
+
"\u0000\u0088\u0089\u0005e\u0000\u0000\u0089\u0094\u0005n\u0000\u0000\u008a"+
|
|
222
|
+
"\u008b\u0005A\u0000\u0000\u008b\u008c\u0005N\u0000\u0000\u008c\u008d\u0005"+
|
|
223
|
+
"D\u0000\u0000\u008d\u008e\u0005_\u0000\u0000\u008e\u008f\u0005G\u0000"+
|
|
224
|
+
"\u0000\u008f\u0090\u0005I\u0000\u0000\u0090\u0091\u0005V\u0000\u0000\u0091"+
|
|
225
|
+
"\u0092\u0005E\u0000\u0000\u0092\u0094\u0005N\u0000\u0000\u0093\u0081\u0001"+
|
|
226
|
+
"\u0000\u0000\u0000\u0093\u008a\u0001\u0000\u0000\u0000\u0094\u000b\u0001"+
|
|
227
|
+
"\u0000\u0000\u0000\u0095\u0096\u0005W\u0000\u0000\u0096\u0097\u0005h\u0000"+
|
|
228
|
+
"\u0000\u0097\u0098\u0005e\u0000\u0000\u0098\u009e\u0005n\u0000\u0000\u0099"+
|
|
229
|
+
"\u009a\u0005W\u0000\u0000\u009a\u009b\u0005H\u0000\u0000\u009b\u009c\u0005"+
|
|
230
|
+
"E\u0000\u0000\u009c\u009e\u0005N\u0000\u0000\u009d\u0095\u0001\u0000\u0000"+
|
|
231
|
+
"\u0000\u009d\u0099\u0001\u0000\u0000\u0000\u009e\r\u0001\u0000\u0000\u0000"+
|
|
232
|
+
"\u009f\u00a0\u0005A\u0000\u0000\u00a0\u00a1\u0005n\u0000\u0000\u00a1\u00a2"+
|
|
233
|
+
"\u0005d\u0000\u0000\u00a2\u00a3\u0005 \u0000\u0000\u00a3\u00a4\u0005w"+
|
|
234
|
+
"\u0000\u0000\u00a4\u00a5\u0005h\u0000\u0000\u00a5\u00a6\u0005e\u0000\u0000"+
|
|
235
|
+
"\u00a6\u00b0\u0005n\u0000\u0000\u00a7\u00a8\u0005A\u0000\u0000\u00a8\u00a9"+
|
|
236
|
+
"\u0005N\u0000\u0000\u00a9\u00aa\u0005D\u0000\u0000\u00aa\u00ab\u0005_"+
|
|
237
|
+
"\u0000\u0000\u00ab\u00ac\u0005W\u0000\u0000\u00ac\u00ad\u0005H\u0000\u0000"+
|
|
238
|
+
"\u00ad\u00ae\u0005E\u0000\u0000\u00ae\u00b0\u0005N\u0000\u0000\u00af\u009f"+
|
|
239
|
+
"\u0001\u0000\u0000\u0000\u00af\u00a7\u0001\u0000\u0000\u0000\u00b0\u000f"+
|
|
240
|
+
"\u0001\u0000\u0000\u0000\u00b1\u00b2\u0005T\u0000\u0000\u00b2\u00b3\u0005"+
|
|
241
|
+
"h\u0000\u0000\u00b3\u00b4\u0005e\u0000\u0000\u00b4\u00ba\u0005n\u0000"+
|
|
242
|
+
"\u0000\u00b5\u00b6\u0005T\u0000\u0000\u00b6\u00b7\u0005H\u0000\u0000\u00b7"+
|
|
243
|
+
"\u00b8\u0005E\u0000\u0000\u00b8\u00ba\u0005N\u0000\u0000\u00b9\u00b1\u0001"+
|
|
244
|
+
"\u0000\u0000\u0000\u00b9\u00b5\u0001\u0000\u0000\u0000\u00ba\u0011\u0001"+
|
|
245
|
+
"\u0000\u0000\u0000\u00bb\u00bc\u0005A\u0000\u0000\u00bc\u00bd\u0005n\u0000"+
|
|
246
|
+
"\u0000\u00bd\u00c2\u0005d\u0000\u0000\u00be\u00bf\u0005A\u0000\u0000\u00bf"+
|
|
247
|
+
"\u00c0\u0005N\u0000\u0000\u00c0\u00c2\u0005D\u0000\u0000\u00c1\u00bb\u0001"+
|
|
248
|
+
"\u0000\u0000\u0000\u00c1\u00be\u0001\u0000\u0000\u0000\u00c2\u0013\u0001"+
|
|
249
|
+
"\u0000\u0000\u0000\u00c3\u00c4\u0005B\u0000\u0000\u00c4\u00c5\u0005u\u0000"+
|
|
250
|
+
"\u0000\u00c5\u00ca\u0005t\u0000\u0000\u00c6\u00c7\u0005B\u0000\u0000\u00c7"+
|
|
251
|
+
"\u00c8\u0005U\u0000\u0000\u00c8\u00ca\u0005T\u0000\u0000\u00c9\u00c3\u0001"+
|
|
252
|
+
"\u0000\u0000\u0000\u00c9\u00c6\u0001\u0000\u0000\u0000\u00ca\u0015\u0001"+
|
|
253
|
+
"\u0000\u0000\u0000\u00cb\u00cc\u0005E\u0000\u0000\u00cc\u00cd\u0005x\u0000"+
|
|
254
|
+
"\u0000\u00cd\u00ce\u0005a\u0000\u0000\u00ce\u00cf\u0005m\u0000\u0000\u00cf"+
|
|
255
|
+
"\u00d0\u0005p\u0000\u0000\u00d0\u00d1\u0005l\u0000\u0000\u00d1\u00d2\u0005"+
|
|
256
|
+
"e\u0000\u0000\u00d2\u00d3\u0005s\u0000\u0000\u00d3\u00dd\u0005:\u0000"+
|
|
257
|
+
"\u0000\u00d4\u00d5\u0005E\u0000\u0000\u00d5\u00d6\u0005X\u0000\u0000\u00d6"+
|
|
258
|
+
"\u00d7\u0005A\u0000\u0000\u00d7\u00d8\u0005M\u0000\u0000\u00d8\u00d9\u0005"+
|
|
259
|
+
"P\u0000\u0000\u00d9\u00da\u0005L\u0000\u0000\u00da\u00db\u0005E\u0000"+
|
|
260
|
+
"\u0000\u00db\u00dd\u0005S\u0000\u0000\u00dc\u00cb\u0001\u0000\u0000\u0000"+
|
|
261
|
+
"\u00dc\u00d4\u0001\u0000\u0000\u0000\u00dd\u0017\u0001\u0000\u0000\u0000"+
|
|
262
|
+
"\u00de\u00df\u0005B\u0000\u0000\u00df\u00e0\u0005a\u0000\u0000\u00e0\u00e1"+
|
|
263
|
+
"\u0005c\u0000\u0000\u00e1\u00e2\u0005k\u0000\u0000\u00e2\u00e3\u0005g"+
|
|
264
|
+
"\u0000\u0000\u00e3\u00e4\u0005r\u0000\u0000\u00e4\u00e5\u0005o\u0000\u0000"+
|
|
265
|
+
"\u00e5\u00e6\u0005u\u0000\u0000\u00e6\u00e7\u0005n\u0000\u0000\u00e7\u00e8"+
|
|
266
|
+
"\u0005d\u0000\u0000\u00e8\u00f4\u0005:\u0000\u0000\u00e9\u00ea\u0005B"+
|
|
267
|
+
"\u0000\u0000\u00ea\u00eb\u0005A\u0000\u0000\u00eb\u00ec\u0005C\u0000\u0000"+
|
|
268
|
+
"\u00ec\u00ed\u0005K\u0000\u0000\u00ed\u00ee\u0005G\u0000\u0000\u00ee\u00ef"+
|
|
269
|
+
"\u0005R\u0000\u0000\u00ef\u00f0\u0005O\u0000\u0000\u00f0\u00f1\u0005U"+
|
|
270
|
+
"\u0000\u0000\u00f1\u00f2\u0005N\u0000\u0000\u00f2\u00f4\u0005D\u0000\u0000"+
|
|
271
|
+
"\u00f3\u00de\u0001\u0000\u0000\u0000\u00f3\u00e9\u0001\u0000\u0000\u0000"+
|
|
272
|
+
"\u00f4\u0019\u0001\u0000\u0000\u0000\u00f5\u00f6\u0005|\u0000\u0000\u00f6"+
|
|
273
|
+
"\u001b\u0001\u0000\u0000\u0000\u00f7\u00f9\u0005@\u0000\u0000\u00f8\u00fa"+
|
|
274
|
+
"\u0007\u0000\u0000\u0000\u00f9\u00f8\u0001\u0000\u0000\u0000\u00fa\u00fb"+
|
|
275
|
+
"\u0001\u0000\u0000\u0000\u00fb\u00f9\u0001\u0000\u0000\u0000\u00fb\u00fc"+
|
|
276
|
+
"\u0001\u0000\u0000\u0000\u00fc\u001d\u0001\u0000\u0000\u0000\u00fd\u0101"+
|
|
277
|
+
"\u0005#\u0000\u0000\u00fe\u0100\b\u0001\u0000\u0000\u00ff\u00fe\u0001"+
|
|
278
|
+
"\u0000\u0000\u0000\u0100\u0103\u0001\u0000\u0000\u0000\u0101\u00ff\u0001"+
|
|
279
|
+
"\u0000\u0000\u0000\u0101\u0102\u0001\u0000\u0000\u0000\u0102\u0104\u0001"+
|
|
280
|
+
"\u0000\u0000\u0000\u0103\u0101\u0001\u0000\u0000\u0000\u0104\u0105\u0006"+
|
|
281
|
+
"\u000e\u0000\u0000\u0105\u001f\u0001\u0000\u0000\u0000\u0106\u0107\b\u0002"+
|
|
282
|
+
"\u0000\u0000\u0107!\u0001\u0000\u0000\u0000\u0108\u010a\u0007\u0001\u0000"+
|
|
283
|
+
"\u0000\u0109\u0108\u0001\u0000\u0000\u0000\u010a\u010b\u0001\u0000\u0000"+
|
|
284
|
+
"\u0000\u010b\u0109\u0001\u0000\u0000\u0000\u010b\u010c\u0001\u0000\u0000"+
|
|
285
|
+
"\u0000\u010c\u010d\u0001\u0000\u0000\u0000\u010d\u010e\u0006\u0010\u0000"+
|
|
286
|
+
"\u0000\u010e#\u0001\u0000\u0000\u0000\u010f\u0111\u0007\u0003\u0000\u0000"+
|
|
287
|
+
"\u0110\u010f\u0001\u0000\u0000\u0000\u0111\u0112\u0001\u0000\u0000\u0000"+
|
|
288
|
+
"\u0112\u0110\u0001\u0000\u0000\u0000\u0112\u0113\u0001\u0000\u0000\u0000"+
|
|
289
|
+
"\u0113\u0114\u0001\u0000\u0000\u0000\u0114\u0115\u0006\u0011\u0000\u0000"+
|
|
290
|
+
"\u0115%\u0001\u0000\u0000\u0000\u0116\u0117\u0005\"\u0000\u0000\u0117"+
|
|
291
|
+
"\u0118\u0005\"\u0000\u0000\u0118\u0119\u0005\"\u0000\u0000\u0119\u011a"+
|
|
292
|
+
"\u0001\u0000\u0000\u0000\u011a\u011b\u0006\u0012\u0001\u0000\u011b\'\u0001"+
|
|
293
|
+
"\u0000\u0000\u0000\u011c\u011e\b\u0004\u0000\u0000\u011d\u011c\u0001\u0000"+
|
|
294
|
+
"\u0000\u0000\u011e\u011f\u0001\u0000\u0000\u0000\u011f\u011d\u0001\u0000"+
|
|
295
|
+
"\u0000\u0000\u011f\u0120\u0001\u0000\u0000\u0000\u0120)\u0001\u0000\u0000"+
|
|
296
|
+
"\u0000\u0121\u0123\u0007\u0003\u0000\u0000\u0122\u0121\u0001\u0000\u0000"+
|
|
297
|
+
"\u0000\u0123\u0124\u0001\u0000\u0000\u0000\u0124\u0122\u0001\u0000\u0000"+
|
|
298
|
+
"\u0000\u0124\u0125\u0001\u0000\u0000\u0000\u0125+\u0001\u0000\u0000\u0000"+
|
|
299
|
+
"\u0126\u0127\u0005\"\u0000\u0000\u0127\u0128\u0005\"\u0000\u0000\u0128"+
|
|
300
|
+
"\u0129\u0005\"\u0000\u0000\u0129\u012a\u0001\u0000\u0000\u0000\u012a\u012b"+
|
|
301
|
+
"\u0006\u0015\u0002\u0000\u012b\u012c\u0006\u0015\u0003\u0000\u012c-\u0001"+
|
|
302
|
+
"\u0000\u0000\u0000\u0014\u0000\u0001=Ps\u007f\u0093\u009d\u00af\u00b9"+
|
|
303
|
+
"\u00c1\u00c9\u00dc\u00f3\u00fb\u0101\u010b\u0112\u011f\u0124\u0004\u0006"+
|
|
304
|
+
"\u0000\u0000\u0005\u0001\u0000\u0007\u0013\u0000\u0004\u0000\u0000";
|
|
305
|
+
public static final ATN _ATN =
|
|
306
|
+
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
|
307
|
+
static {
|
|
308
|
+
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
|
|
309
|
+
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
|
|
310
|
+
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
FEATURE=1
|
|
2
|
+
SCENARIO=2
|
|
3
|
+
SCENARIO_OUTLINE=3
|
|
4
|
+
GIVEN=4
|
|
5
|
+
AND_GIVEN=5
|
|
6
|
+
WHEN=6
|
|
7
|
+
AND_WHEN=7
|
|
8
|
+
THEN=8
|
|
9
|
+
AND=9
|
|
10
|
+
BUT=10
|
|
11
|
+
EXAMPLES=11
|
|
12
|
+
BACKGROUND=12
|
|
13
|
+
PIPE=13
|
|
14
|
+
TAG=14
|
|
15
|
+
COMMENT=15
|
|
16
|
+
TEXT_CHARACTER=16
|
|
17
|
+
WS=17
|
|
18
|
+
WSS=18
|
|
19
|
+
DOC_STRING_QUOT=19
|
|
20
|
+
DOC_STRING_TEXT=20
|
|
21
|
+
DOC_STRING_WS=21
|
|
22
|
+
'|'=13
|
package/grammar.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
npx antlr4ts -visitor -no-listener ./src/grammar/GherkinLexer.g4
|
|
4
|
+
npx antlr4ts -visitor -no-listener ./src/grammar/GherkinParser.g4
|
|
5
|
+
|
|
6
|
+
echo "// @ts-nocheck" | cat - ./src/grammar/GherkinLexer.ts > temp && mv temp ./src/grammar/GherkinLexer.ts
|
|
7
|
+
echo "// @ts-nocheck" | cat - ./src/grammar/GherkinParser.ts > temp && mv temp ./src/grammar/GherkinParser.ts
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testMatch: [
|
|
3
|
+
'<rootDir>/test/runner.ts'
|
|
4
|
+
],
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.[tj]s$': ['ts-jest', {
|
|
7
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
8
|
+
}]
|
|
9
|
+
},
|
|
10
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
11
|
+
coverageDirectory: '../coverage/',
|
|
12
|
+
};
|
package/nodemon.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pickle-jar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/types/index.d.ts",
|
|
6
|
+
"repository": "git@github.com:nseba/pickle-jar.git",
|
|
7
|
+
"author": "Sebastian Negomireanu",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/glob": "^8.1.0",
|
|
11
|
+
"@types/jest": "^29.5.1",
|
|
12
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
13
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
14
|
+
"antlr4": "^4.13.0",
|
|
15
|
+
"antlr4ts": "^0.5.0-alpha.4",
|
|
16
|
+
"antlr4ts-cli": "^0.5.0-alpha.4",
|
|
17
|
+
"eslint": "^8.41.0",
|
|
18
|
+
"eslint-config-prettier": "^8.8.0",
|
|
19
|
+
"glob": "^10.2.6",
|
|
20
|
+
"jest": "^29.5.0",
|
|
21
|
+
"ts-jest": "^29.1.0",
|
|
22
|
+
"tsc-watch": "^6.0.4",
|
|
23
|
+
"typescript": "^4.9.5"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"antlr4": "^4.13.0",
|
|
27
|
+
"antlr4ts": "^0.5.0-alpha.4",
|
|
28
|
+
"glob": "^10.2.6"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {AbstractParseTreeVisitor} from "antlr4ts/tree";
|
|
2
|
+
import {EOL} from "os";
|
|
3
|
+
import {
|
|
4
|
+
AndGivenStepContext,
|
|
5
|
+
AndStepContext,
|
|
6
|
+
AndWhenStepContext,
|
|
7
|
+
ButStepContext,
|
|
8
|
+
FeatureContext,
|
|
9
|
+
GivenStepContext,
|
|
10
|
+
ScenarioContext,
|
|
11
|
+
ScenarioOutlineContext,
|
|
12
|
+
ThenStepContext,
|
|
13
|
+
WhenStepContext
|
|
14
|
+
} from "./grammar/GherkinParser";
|
|
15
|
+
import {GherkinParserVisitor} from "./grammar/GherkinParserVisitor";
|
|
16
|
+
import {StepDefinition} from "./step-definition";
|
|
17
|
+
|
|
18
|
+
export class FeatureFileVisitor<TWorld> extends AbstractParseTreeVisitor<void> implements GherkinParserVisitor<void> {
|
|
19
|
+
constructor(public readonly world: TWorld, public readonly stepDefinitions: StepDefinition<TWorld>[]) {
|
|
20
|
+
super();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public visitFeature(ctx: FeatureContext): void {
|
|
24
|
+
describe(`Feature: ${ctx.contentText().text.trim()}`, () => {
|
|
25
|
+
this.visitChildren(ctx);
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public visitScenario(ctx: ScenarioContext): void {
|
|
30
|
+
describe(`Scenario: ${ctx.contentText().text.trim()}`, () => {
|
|
31
|
+
const step = ctx.step();
|
|
32
|
+
|
|
33
|
+
const steps = [step.givenStep(), ...step.andGivenStep(), step.whenStep(), ...step.andWhenStep(), step.thenStep(), ...step.andStep(), ...step.butStep()];
|
|
34
|
+
|
|
35
|
+
this.runNextStep(steps);
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public visitScenarioOutline(ctx: ScenarioOutlineContext): void {
|
|
40
|
+
const cellNames = ctx.examplesBlock().tableHeader().tableRow().cell().map(cell => cell.text.trim());
|
|
41
|
+
const values = ctx.examplesBlock().tableRow().map(row => row.cell().map(cell => cell.text.trim()));
|
|
42
|
+
|
|
43
|
+
const valueMap = values.map(row => {
|
|
44
|
+
const item: Record<string, string> = {};
|
|
45
|
+
for (let i = 0; i < row.length; ++i) {
|
|
46
|
+
item[cellNames[i]] = row[i];
|
|
47
|
+
}
|
|
48
|
+
return item;
|
|
49
|
+
})
|
|
50
|
+
const scenarioName = ctx.contentText().text.trim();
|
|
51
|
+
|
|
52
|
+
describe(`Scenario outline: ${scenarioName}`, () => {
|
|
53
|
+
for (const row of valueMap) {
|
|
54
|
+
|
|
55
|
+
const step = ctx.step();
|
|
56
|
+
|
|
57
|
+
const steps = [step.givenStep(), ...step.andGivenStep(), step.whenStep(), ...step.andWhenStep(), step.thenStep(), ...step.andStep(), ...step.butStep()];
|
|
58
|
+
|
|
59
|
+
this.runNextStep(steps, row);
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected defaultResult(): void {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private replaceKeywords(input: string, replacements: Record<string, string> | undefined): string {
|
|
70
|
+
return input.replace(/<([^>]+)>/g, (match, keyword) => {
|
|
71
|
+
const replacement = replacements?.[keyword];
|
|
72
|
+
return replacement !== undefined ? replacement : match;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private runNextStep(steps: (GivenStepContext | AndGivenStepContext | WhenStepContext | AndWhenStepContext | ThenStepContext | AndStepContext | ButStepContext)[], valueMap?: Record<string, string>) {
|
|
77
|
+
const step = steps.shift();
|
|
78
|
+
if (!step) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let prefix: string;
|
|
83
|
+
let prepare = true;
|
|
84
|
+
if (step instanceof GivenStepContext || step instanceof AndGivenStepContext) {
|
|
85
|
+
prefix = 'Given';
|
|
86
|
+
} else if (step instanceof WhenStepContext || step instanceof AndWhenStepContext) {
|
|
87
|
+
prefix = 'When';
|
|
88
|
+
} else if (step instanceof ThenStepContext || step instanceof AndStepContext) {
|
|
89
|
+
prefix = "Then";
|
|
90
|
+
prepare = false;
|
|
91
|
+
} else {
|
|
92
|
+
prefix = 'But';
|
|
93
|
+
prepare = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const name = `${prefix} ${this.replaceKeywords(step.contentText().text.trim(), valueMap)}`;
|
|
97
|
+
const stepDefinition = this.getMatchingStepDefinition(name);
|
|
98
|
+
|
|
99
|
+
const {step: stepCall, match} = stepDefinition;
|
|
100
|
+
|
|
101
|
+
const docStringContents = step.docString()?.DOC_STRING_TEXT()?.text;
|
|
102
|
+
const args = this.extractTestArgs(match, name, docStringContents, valueMap);
|
|
103
|
+
|
|
104
|
+
if (prepare) {
|
|
105
|
+
this.definePrepareStep(name, stepCall, args, steps, valueMap);
|
|
106
|
+
} else {
|
|
107
|
+
this.defineTestStep(name, stepCall, args, steps, valueMap);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private defineTestStep(name: string, stepCall: (world: TWorld, ...params: string[]) => void, args: string[], steps: (GivenStepContext | AndGivenStepContext | WhenStepContext | AndWhenStepContext | ThenStepContext | AndStepContext | ButStepContext)[], valueMap: Record<string, string> | undefined) {
|
|
113
|
+
it(name, () => {
|
|
114
|
+
stepCall(this.world, ...args);
|
|
115
|
+
})
|
|
116
|
+
this.runNextStep(steps, valueMap);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private definePrepareStep(name: string, stepCall: (world: TWorld, ...params: string[]) => void, args: string[], steps: (GivenStepContext | AndGivenStepContext | WhenStepContext | AndWhenStepContext | ThenStepContext | AndStepContext | ButStepContext)[], valueMap: Record<string, string> | undefined) {
|
|
120
|
+
describe(name, () => {
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
stepCall(this.world, ...args);
|
|
123
|
+
});
|
|
124
|
+
this.runNextStep(steps, valueMap)
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private extractTestArgs(match: RegExp, name: string, docStringContents: string | undefined, valueMap: Record<string, string> | undefined) {
|
|
129
|
+
let args: string [] = [];
|
|
130
|
+
const matchResults = match.exec(name);
|
|
131
|
+
if (matchResults) {
|
|
132
|
+
args = matchResults.slice(1);
|
|
133
|
+
}
|
|
134
|
+
if (docStringContents) {
|
|
135
|
+
const cleanedDocstring = this.replaceKeywords(docStringContents.trim()
|
|
136
|
+
.split(/((\r\n)|\r|\n)]/)
|
|
137
|
+
.map(line => line.trimStart()).join(EOL), valueMap)
|
|
138
|
+
args.push(cleanedDocstring);
|
|
139
|
+
}
|
|
140
|
+
return args;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private getMatchingStepDefinition(name: string) {
|
|
144
|
+
const matchingStepDefinitions = this.stepDefinitions.filter(def => {
|
|
145
|
+
return def.match.test(name);
|
|
146
|
+
});
|
|
147
|
+
if (!matchingStepDefinitions.length) {
|
|
148
|
+
throw new Error(`Missing step definition '${name}'`);
|
|
149
|
+
} else if (matchingStepDefinitions.length > 1) {
|
|
150
|
+
throw new Error(`Multiple step definition match '${name}':\n${matchingStepDefinitions.map(rule => rule.match.toString()).join("\n")}`);
|
|
151
|
+
}
|
|
152
|
+
return matchingStepDefinitions[0];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function getCallSites() {
|
|
2
|
+
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
3
|
+
Error.prepareStackTrace = (_, stack) => stack;
|
|
4
|
+
const stack = (new Error().stack as unknown as NodeJS.CallSite[]).slice(1);
|
|
5
|
+
Error.prepareStackTrace = oldPrepareStackTrace;
|
|
6
|
+
return stack;
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
lexer grammar GherkinLexer;
|
|
2
|
+
|
|
3
|
+
FEATURE: 'Feature:' | 'FEATURE';
|
|
4
|
+
SCENARIO: 'Scenario:' | 'SCENARIO';
|
|
5
|
+
SCENARIO_OUTLINE: 'Scenario Outline:' | 'SCENARIO_OUTLINE';
|
|
6
|
+
GIVEN: 'Given' | 'GIVEN';
|
|
7
|
+
AND_GIVEN: 'And given' | 'AND_GIVEN';
|
|
8
|
+
WHEN: 'When' | 'WHEN';
|
|
9
|
+
AND_WHEN: 'And when' | 'AND_WHEN';
|
|
10
|
+
THEN: 'Then' | 'THEN';
|
|
11
|
+
AND: 'And' | 'AND';
|
|
12
|
+
BUT: 'But' | 'BUT';
|
|
13
|
+
EXAMPLES: 'Examples:' | 'EXAMPLES';
|
|
14
|
+
BACKGROUND: 'Background:' | 'BACKGROUND';
|
|
15
|
+
|
|
16
|
+
PIPE: '|';
|
|
17
|
+
TAG: '@' [a-zA-Z0-9_]+;
|
|
18
|
+
COMMENT: '#' ~[\r\n]* -> skip;
|
|
19
|
+
|
|
20
|
+
TEXT_CHARACTER: ~[\r\n"];
|
|
21
|
+
WS: [\r\n]+ -> skip;
|
|
22
|
+
WSS: [ \t\r\n]+ -> skip;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
DOC_STRING_QUOT: '"""' -> pushMode(DOC_STRING_MODE);
|
|
26
|
+
mode DOC_STRING_MODE;
|
|
27
|
+
DOC_STRING_TEXT: ~["]+;
|
|
28
|
+
DOC_STRING_WS: [ \t\r\n]+;
|
|
29
|
+
DOC_STRING_QUOT_2: '"""' -> type(DOC_STRING_QUOT), popMode;
|