@cucumber/query 7.0.1 → 9.0.2
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/.mocharc.json +2 -2
- package/default.mk +19 -47
- package/dist/src/Query.d.ts +1 -0
- package/dist/src/Query.d.ts.map +1 -0
- package/dist/src/Query.js +57 -95
- package/dist/src/Query.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -4
- package/dist/src/index.js.map +1 -1
- package/dist/test/QueryTest.d.ts +2 -1
- package/dist/test/QueryTest.d.ts.map +1 -0
- package/dist/test/QueryTest.js +329 -455
- package/dist/test/QueryTest.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +5082 -0
- package/package.json +12 -30
- package/src/Query.ts +19 -61
- package/src/index.ts +1 -2
- package/test/QueryTest.ts +43 -113
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +1 -24
- package/.built +0 -0
- package/.codegen +0 -0
- package/.deps +0 -0
- package/.eslintrc.json +0 -41
- package/.gitignore +0 -18
- package/.idea/aws.xml +0 -11
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/javascript.iml +0 -9
- package/.idea/misc.xml +0 -9
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -101
- package/.linted +0 -0
- package/.nycrc.json +0 -16
- package/.prettierrc +0 -5
- package/.tested-npm +0 -0
- package/dist/src/QueryStream.d.ts +0 -9
- package/dist/src/QueryStream.js +0 -31
- package/dist/src/QueryStream.js.map +0 -1
- package/package-lock.json +0 -3604
- package/src/QueryStream.ts +0 -18
package/dist/test/QueryTest.js
CHANGED
|
@@ -8,60 +8,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
require("
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
describe('Query', function () {
|
|
56
|
-
var gherkinQuery;
|
|
57
|
-
var cucumberQuery;
|
|
58
|
-
beforeEach(function () {
|
|
15
|
+
const gherkin_streams_1 = require("@cucumber/gherkin-streams");
|
|
16
|
+
const gherkin_utils_1 = require("@cucumber/gherkin-utils");
|
|
17
|
+
const messages_1 = require("@cucumber/messages");
|
|
18
|
+
const stream_1 = require("stream");
|
|
19
|
+
const assert_1 = __importDefault(require("assert"));
|
|
20
|
+
const fake_cucumber_1 = require("@cucumber/fake-cucumber");
|
|
21
|
+
const util_1 = require("util");
|
|
22
|
+
const Query_1 = __importDefault(require("../src/Query"));
|
|
23
|
+
const pipelinePromise = util_1.promisify(stream_1.pipeline);
|
|
24
|
+
describe('Query', () => {
|
|
25
|
+
let gherkinQuery;
|
|
26
|
+
let cucumberQuery;
|
|
27
|
+
beforeEach(() => {
|
|
59
28
|
gherkinQuery = new gherkin_utils_1.Query();
|
|
60
29
|
cucumberQuery = new Query_1.default();
|
|
61
30
|
});
|
|
62
|
-
describe('#getWorstTestStepResult(testStepResults)',
|
|
63
|
-
it('returns a FAILED result for PASSED,FAILED,PASSED',
|
|
64
|
-
|
|
31
|
+
describe('#getWorstTestStepResult(testStepResults)', () => {
|
|
32
|
+
it('returns a FAILED result for PASSED,FAILED,PASSED', () => {
|
|
33
|
+
const result = cucumberQuery.getWorstTestStepResult([
|
|
65
34
|
new messages_1.messages.TestStepFinished.TestStepResult({
|
|
66
35
|
status: messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
67
36
|
}),
|
|
@@ -75,447 +44,352 @@ describe('Query', function () {
|
|
|
75
44
|
assert_1.default.strictEqual(result.status, messages_1.messages.TestStepFinished.TestStepResult.Status.FAILED);
|
|
76
45
|
});
|
|
77
46
|
});
|
|
78
|
-
describe('#getPickleStepTestStepResults(pickleStepIds)',
|
|
79
|
-
it('returns a single UNKNOWN when the list is empty',
|
|
80
|
-
|
|
81
|
-
assert_1.default.deepStrictEqual(results.map(
|
|
47
|
+
describe('#getPickleStepTestStepResults(pickleStepIds)', () => {
|
|
48
|
+
it('returns a single UNKNOWN when the list is empty', () => {
|
|
49
|
+
const results = cucumberQuery.getPickleTestStepResults([]);
|
|
50
|
+
assert_1.default.deepStrictEqual(results.map((r) => r.status), [messages_1.messages.TestStepFinished.TestStepResult.Status.UNKNOWN]);
|
|
82
51
|
});
|
|
83
|
-
it('looks up results for scenario steps',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
assert_1.default.strictEqual(pickleStepIds.length, 0);
|
|
135
|
-
testStepResults = cucumberQuery.getPickleStepTestStepResults(pickleStepIds);
|
|
136
|
-
assert_1.default.strictEqual(testStepResults.length, 1);
|
|
137
|
-
assert_1.default.strictEqual(testStepResults[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.UNKNOWN);
|
|
138
|
-
return [2 /*return*/];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); });
|
|
52
|
+
it('looks up results for scenario steps', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const envelopes = [];
|
|
54
|
+
yield execute(`Feature: hello
|
|
55
|
+
Scenario: ok
|
|
56
|
+
Given a passed step
|
|
57
|
+
`, (envelope) => envelopes.push(envelope));
|
|
58
|
+
const scenario = findScenario(envelopes);
|
|
59
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(scenario.steps[0].id);
|
|
60
|
+
assert_1.default.strictEqual(pickleStepIds.length, 1);
|
|
61
|
+
const testStepResults = cucumberQuery.getPickleStepTestStepResults(pickleStepIds);
|
|
62
|
+
assert_1.default.strictEqual(testStepResults.length, 1);
|
|
63
|
+
assert_1.default.strictEqual(testStepResults[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED);
|
|
64
|
+
}));
|
|
65
|
+
it('looks up results for background steps', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const envelopes = [];
|
|
67
|
+
yield execute(`Feature: hello
|
|
68
|
+
Background:
|
|
69
|
+
Given a passed step
|
|
70
|
+
|
|
71
|
+
Scenario: ok
|
|
72
|
+
Given a passed step
|
|
73
|
+
|
|
74
|
+
Scenario: ko
|
|
75
|
+
Given a failed step
|
|
76
|
+
`, (envelope) => envelopes.push(envelope));
|
|
77
|
+
const background = findBackground(envelopes);
|
|
78
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(background.steps[0].id);
|
|
79
|
+
assert_1.default.strictEqual(pickleStepIds.length, 2);
|
|
80
|
+
const testStepResults = cucumberQuery.getPickleStepTestStepResults(pickleStepIds);
|
|
81
|
+
assert_1.default.deepStrictEqual(testStepResults.map((r) => r.status), [
|
|
82
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
83
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
84
|
+
]);
|
|
85
|
+
}));
|
|
86
|
+
it('looks up results for background steps when scenarios are empty', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
const envelopes = [];
|
|
88
|
+
yield execute(`Feature: hello
|
|
89
|
+
Background:
|
|
90
|
+
Given a passed step
|
|
91
|
+
|
|
92
|
+
Scenario: ok
|
|
93
|
+
|
|
94
|
+
Scenario: ok too
|
|
95
|
+
`, (envelope) => envelopes.push(envelope));
|
|
96
|
+
const background = findBackground(envelopes);
|
|
97
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(background.steps[0].id);
|
|
98
|
+
assert_1.default.strictEqual(pickleStepIds.length, 0);
|
|
99
|
+
const testStepResults = cucumberQuery.getPickleStepTestStepResults(pickleStepIds);
|
|
100
|
+
assert_1.default.strictEqual(testStepResults.length, 1);
|
|
101
|
+
assert_1.default.strictEqual(testStepResults[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.UNKNOWN);
|
|
102
|
+
}));
|
|
142
103
|
});
|
|
143
|
-
describe('#getPickleTestStepResults(pickleIds)',
|
|
144
|
-
it('looks up results for scenarios',
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
]);
|
|
210
|
-
return [2 /*return*/];
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}); });
|
|
104
|
+
describe('#getPickleTestStepResults(pickleIds)', () => {
|
|
105
|
+
it('looks up results for scenarios', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
const envelopes = [];
|
|
107
|
+
yield execute(`Feature: hello
|
|
108
|
+
Scenario: ko
|
|
109
|
+
Given a passed step
|
|
110
|
+
Given a failed step
|
|
111
|
+
`, (envelope) => envelopes.push(envelope));
|
|
112
|
+
const scenario = findScenario(envelopes);
|
|
113
|
+
const pickleIds = gherkinQuery.getPickleIds('test.feature', scenario.id);
|
|
114
|
+
assert_1.default.strictEqual(pickleIds.length, 1);
|
|
115
|
+
const testStepResults = cucumberQuery.getPickleTestStepResults(pickleIds);
|
|
116
|
+
assert_1.default.deepStrictEqual(testStepResults.map((r) => r.status), [
|
|
117
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
118
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
119
|
+
]);
|
|
120
|
+
}));
|
|
121
|
+
it('looks up results for scenario outlines', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
const envelopes = [];
|
|
123
|
+
yield execute(`Feature: hello
|
|
124
|
+
Scenario: hi <status1> and <status2>
|
|
125
|
+
Given a <status1> step
|
|
126
|
+
And a <status2> step
|
|
127
|
+
|
|
128
|
+
Examples:
|
|
129
|
+
| status1 | status2 |
|
|
130
|
+
| passed | passed |
|
|
131
|
+
| passed | failed |
|
|
132
|
+
`, (envelope) => envelopes.push(envelope));
|
|
133
|
+
const scenario = findScenario(envelopes);
|
|
134
|
+
const pickleIds = gherkinQuery.getPickleIds('test.feature', scenario.id);
|
|
135
|
+
assert_1.default.strictEqual(pickleIds.length, 2);
|
|
136
|
+
assert_1.default.deepStrictEqual(cucumberQuery.getPickleTestStepResults(pickleIds).map((r) => r.status), [
|
|
137
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
138
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
139
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
140
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
141
|
+
]);
|
|
142
|
+
}));
|
|
143
|
+
it('looks up results for examples rows outlines', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const envelopes = [];
|
|
145
|
+
yield execute(`Feature: hello
|
|
146
|
+
Scenario: hi <status1> and <status2>
|
|
147
|
+
Given a <status1> step
|
|
148
|
+
And a <status2> step
|
|
149
|
+
|
|
150
|
+
Examples:
|
|
151
|
+
| status1 | status2 |
|
|
152
|
+
| passed | passed |
|
|
153
|
+
| passed | failed |
|
|
154
|
+
`, (envelope) => envelopes.push(envelope));
|
|
155
|
+
const scenario = findScenario(envelopes);
|
|
156
|
+
const exampleIds = scenario.examples[0].tableBody.map((row) => row.id);
|
|
157
|
+
assert_1.default.deepStrictEqual(cucumberQuery
|
|
158
|
+
.getPickleTestStepResults(gherkinQuery.getPickleIds('test.feature', exampleIds[0]))
|
|
159
|
+
.map((r) => r.status), [
|
|
160
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
161
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
162
|
+
]);
|
|
163
|
+
assert_1.default.deepStrictEqual(cucumberQuery
|
|
164
|
+
.getPickleTestStepResults(gherkinQuery.getPickleIds('test.feature', exampleIds[1]))
|
|
165
|
+
.map((r) => r.status), [
|
|
166
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
167
|
+
messages_1.messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
168
|
+
]);
|
|
169
|
+
}));
|
|
214
170
|
});
|
|
215
|
-
describe('#getPickleStepAttachments(pickleIds)',
|
|
216
|
-
it('looks up attachments',
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
assert_1.default.strictEqual(attachments.length, 1);
|
|
230
|
-
assert_1.default.strictEqual(attachments[0].body, 'Hello');
|
|
231
|
-
return [2 /*return*/];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}); });
|
|
171
|
+
describe('#getPickleStepAttachments(pickleIds)', () => {
|
|
172
|
+
it('looks up attachments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
const envelopes = [];
|
|
174
|
+
yield execute(`Feature: hello
|
|
175
|
+
Scenario: ok
|
|
176
|
+
Given a passed step with attachment
|
|
177
|
+
`, (envelope) => envelopes.push(envelope));
|
|
178
|
+
const scenario = findScenario(envelopes);
|
|
179
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(scenario.steps[0].id);
|
|
180
|
+
assert_1.default.strictEqual(pickleStepIds.length, 1);
|
|
181
|
+
const attachments = cucumberQuery.getPickleStepAttachments(pickleStepIds);
|
|
182
|
+
assert_1.default.strictEqual(attachments.length, 1);
|
|
183
|
+
assert_1.default.strictEqual(attachments[0].body, 'Hello');
|
|
184
|
+
}));
|
|
235
185
|
});
|
|
236
|
-
describe('#getStepMatchArguments(uri, lineNumber)',
|
|
237
|
-
it("looks up result for step's uri and line",
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
case 1:
|
|
286
|
-
_a.sent();
|
|
287
|
-
scenarioId = findScenario(envelopes).id;
|
|
288
|
-
pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
289
|
-
assert_1.default.strictEqual(cucumberQuery.getBeforeHookSteps(pickleId).length, 1);
|
|
290
|
-
return [2 /*return*/];
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}); });
|
|
294
|
-
it('does not return after hook steps', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
295
|
-
var envelopes, scenarioId, pickleId;
|
|
296
|
-
return __generator(this, function (_a) {
|
|
297
|
-
switch (_a.label) {
|
|
298
|
-
case 0:
|
|
299
|
-
envelopes = [];
|
|
300
|
-
return [4 /*yield*/, execute("Feature: hello\n @afterHook\n Scenario: hi\n Given a passed step\n ", function (envelope) { return envelopes.push(envelope); })];
|
|
301
|
-
case 1:
|
|
302
|
-
_a.sent();
|
|
303
|
-
scenarioId = findScenario(envelopes).id;
|
|
304
|
-
pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
305
|
-
assert_1.default.deepStrictEqual(cucumberQuery.getBeforeHookSteps(pickleId), []);
|
|
306
|
-
return [2 /*return*/];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}); });
|
|
186
|
+
describe('#getStepMatchArguments(uri, lineNumber)', () => {
|
|
187
|
+
it("looks up result for step's uri and line", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
188
|
+
const envelopes = [];
|
|
189
|
+
yield execute(`Feature: hello
|
|
190
|
+
Scenario: ok
|
|
191
|
+
Given a passed step
|
|
192
|
+
And I have 567 cukes in my belly
|
|
193
|
+
`, (envelope) => envelopes.push(envelope));
|
|
194
|
+
const scenario = findScenario(envelopes);
|
|
195
|
+
assert_1.default.deepStrictEqual(cucumberQuery
|
|
196
|
+
.getStepMatchArgumentsLists(gherkinQuery.getPickleStepIds(scenario.steps[0].id)[0])
|
|
197
|
+
.map((sal) => sal.stepMatchArguments.map((arg) => arg.parameterTypeName)), [[]]);
|
|
198
|
+
assert_1.default.deepStrictEqual(cucumberQuery
|
|
199
|
+
.getStepMatchArgumentsLists(gherkinQuery.getPickleStepIds(scenario.steps[1].id)[0])
|
|
200
|
+
.map((sal) => sal.stepMatchArguments.map((arg) => arg.parameterTypeName)), [['int', 'word']]);
|
|
201
|
+
}));
|
|
202
|
+
describe('#getBeforeHookSteps(pickleId: string)', () => {
|
|
203
|
+
it('returns an empty list when there is no hooks', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
204
|
+
const envelopes = [];
|
|
205
|
+
yield execute(`Feature: hello
|
|
206
|
+
Scenario: hi
|
|
207
|
+
Given a passed step
|
|
208
|
+
`, (envelope) => envelopes.push(envelope));
|
|
209
|
+
const scenarioId = findScenario(envelopes).id;
|
|
210
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
211
|
+
assert_1.default.deepStrictEqual(cucumberQuery.getBeforeHookSteps(pickleId), []);
|
|
212
|
+
}));
|
|
213
|
+
it('returns one before hook step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
214
|
+
const envelopes = [];
|
|
215
|
+
yield execute(`Feature: hello
|
|
216
|
+
@beforeHook
|
|
217
|
+
Scenario: hi
|
|
218
|
+
Given a passed step
|
|
219
|
+
`, (envelope) => envelopes.push(envelope));
|
|
220
|
+
const scenarioId = findScenario(envelopes).id;
|
|
221
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
222
|
+
assert_1.default.strictEqual(cucumberQuery.getBeforeHookSteps(pickleId).length, 1);
|
|
223
|
+
}));
|
|
224
|
+
it('does not return after hook steps', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
|
+
const envelopes = [];
|
|
226
|
+
yield execute(`Feature: hello
|
|
227
|
+
@afterHook
|
|
228
|
+
Scenario: hi
|
|
229
|
+
Given a passed step
|
|
230
|
+
`, (envelope) => envelopes.push(envelope));
|
|
231
|
+
const scenarioId = findScenario(envelopes).id;
|
|
232
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
233
|
+
assert_1.default.deepStrictEqual(cucumberQuery.getBeforeHookSteps(pickleId), []);
|
|
234
|
+
}));
|
|
310
235
|
});
|
|
311
|
-
describe('#getAfterHookSteps(pickleId: string)',
|
|
312
|
-
it('returns an empty list when there is no hooks',
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
})
|
|
344
|
-
it('does not return before hook steps', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
345
|
-
var envelopes, scenarioId, pickleId;
|
|
346
|
-
return __generator(this, function (_a) {
|
|
347
|
-
switch (_a.label) {
|
|
348
|
-
case 0:
|
|
349
|
-
envelopes = [];
|
|
350
|
-
return [4 /*yield*/, execute("Feature: hello\n @beforeHook\n Scenario: hi\n Given a passed step\n ", function (envelope) { return envelopes.push(envelope); })];
|
|
351
|
-
case 1:
|
|
352
|
-
_a.sent();
|
|
353
|
-
scenarioId = findScenario(envelopes).id;
|
|
354
|
-
pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
355
|
-
assert_1.default.deepStrictEqual(cucumberQuery.getAfterHookSteps(pickleId), []);
|
|
356
|
-
return [2 /*return*/];
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
}); });
|
|
236
|
+
describe('#getAfterHookSteps(pickleId: string)', () => {
|
|
237
|
+
it('returns an empty list when there is no hooks', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
238
|
+
const envelopes = [];
|
|
239
|
+
yield execute(`Feature: hello
|
|
240
|
+
Scenario: hi
|
|
241
|
+
Given a passed step
|
|
242
|
+
`, (envelope) => envelopes.push(envelope));
|
|
243
|
+
const scenarioId = findScenario(envelopes).id;
|
|
244
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
245
|
+
assert_1.default.deepStrictEqual(cucumberQuery.getAfterHookSteps(pickleId), []);
|
|
246
|
+
}));
|
|
247
|
+
it('returns one after hook step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
+
const envelopes = [];
|
|
249
|
+
yield execute(`Feature: hello
|
|
250
|
+
@afterHook
|
|
251
|
+
Scenario: hi
|
|
252
|
+
Given a passed step
|
|
253
|
+
`, (envelope) => envelopes.push(envelope));
|
|
254
|
+
const scenarioId = findScenario(envelopes).id;
|
|
255
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
256
|
+
assert_1.default.strictEqual(cucumberQuery.getAfterHookSteps(pickleId).length, 1);
|
|
257
|
+
}));
|
|
258
|
+
it('does not return before hook steps', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
259
|
+
const envelopes = [];
|
|
260
|
+
yield execute(`Feature: hello
|
|
261
|
+
@beforeHook
|
|
262
|
+
Scenario: hi
|
|
263
|
+
Given a passed step
|
|
264
|
+
`, (envelope) => envelopes.push(envelope));
|
|
265
|
+
const scenarioId = findScenario(envelopes).id;
|
|
266
|
+
const pickleId = gherkinQuery.getPickleIds('test.feature', scenarioId)[0];
|
|
267
|
+
assert_1.default.deepStrictEqual(cucumberQuery.getAfterHookSteps(pickleId), []);
|
|
268
|
+
}));
|
|
360
269
|
});
|
|
361
|
-
describe('#getTestStepResult',
|
|
362
|
-
it('returns one test step result',
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return [4 /*yield*/, execute("Feature: hello\n @beforeHook\n Scenario: hi\n Given a passed step\n ", function (message) { return emittedMessages.push(message); })];
|
|
388
|
-
case 1:
|
|
389
|
-
_a.sent();
|
|
390
|
-
testCase = emittedMessages.find(function (child) { return child.testCase; })
|
|
391
|
-
.testCase;
|
|
392
|
-
testStep = testCase.testSteps[0];
|
|
393
|
-
results = cucumberQuery.getTestStepResults(testStep.id);
|
|
394
|
-
assert_1.default.deepStrictEqual(results.length, 1);
|
|
395
|
-
assert_1.default.deepStrictEqual(results[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED);
|
|
396
|
-
return [2 /*return*/];
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}); });
|
|
270
|
+
describe('#getTestStepResult', () => {
|
|
271
|
+
it('returns one test step result', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
272
|
+
const emittedMessages = [];
|
|
273
|
+
yield execute(`Feature: hello
|
|
274
|
+
Scenario: hi
|
|
275
|
+
Given a passed step
|
|
276
|
+
`, (message) => emittedMessages.push(message));
|
|
277
|
+
const testCase = emittedMessages.find((child) => child.testCase).testCase;
|
|
278
|
+
const testStep = testCase.testSteps[0];
|
|
279
|
+
const results = cucumberQuery.getTestStepResults(testStep.id);
|
|
280
|
+
assert_1.default.deepStrictEqual(results.length, 1);
|
|
281
|
+
assert_1.default.deepStrictEqual(results[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED);
|
|
282
|
+
}));
|
|
283
|
+
it('returns a result for hook step', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
284
|
+
const emittedMessages = [];
|
|
285
|
+
yield execute(`Feature: hello
|
|
286
|
+
@beforeHook
|
|
287
|
+
Scenario: hi
|
|
288
|
+
Given a passed step
|
|
289
|
+
`, (message) => emittedMessages.push(message));
|
|
290
|
+
const testCase = emittedMessages.find((child) => child.testCase).testCase;
|
|
291
|
+
const testStep = testCase.testSteps[0];
|
|
292
|
+
const results = cucumberQuery.getTestStepResults(testStep.id);
|
|
293
|
+
assert_1.default.deepStrictEqual(results.length, 1);
|
|
294
|
+
assert_1.default.deepStrictEqual(results[0].status, messages_1.messages.TestStepFinished.TestStepResult.Status.PASSED);
|
|
295
|
+
}));
|
|
400
296
|
});
|
|
401
|
-
describe('#getHook(HookId)',
|
|
402
|
-
it('returns undefined if the id does not match any hook',
|
|
297
|
+
describe('#getHook(HookId)', () => {
|
|
298
|
+
it('returns undefined if the id does not match any hook', () => {
|
|
403
299
|
assert_1.default.strictEqual(cucumberQuery.getHook('tralala'), undefined);
|
|
404
300
|
});
|
|
405
|
-
it('returns the matching hook',
|
|
406
|
-
|
|
301
|
+
it('returns the matching hook', () => {
|
|
302
|
+
const hook = messages_1.messages.Hook.create({
|
|
407
303
|
id: 'tralala',
|
|
408
304
|
});
|
|
409
|
-
|
|
410
|
-
hook
|
|
305
|
+
const envelope = messages_1.messages.Envelope.create({
|
|
306
|
+
hook,
|
|
411
307
|
});
|
|
412
308
|
cucumberQuery.update(envelope);
|
|
413
309
|
assert_1.default.deepStrictEqual(cucumberQuery.getHook('tralala'), hook);
|
|
414
310
|
});
|
|
415
311
|
});
|
|
416
|
-
describe('#getAttachmentByTestStepId',
|
|
417
|
-
it('looks up attachments',
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
testCases.push(envelope.testCase);
|
|
426
|
-
}
|
|
427
|
-
})];
|
|
428
|
-
case 1:
|
|
429
|
-
_a.sent();
|
|
430
|
-
attachments = cucumberQuery.getTestStepsAttachments([
|
|
431
|
-
testCases[0].testSteps[0].id,
|
|
432
|
-
]);
|
|
433
|
-
assert_1.default.strictEqual(attachments.length, 1);
|
|
434
|
-
assert_1.default.strictEqual(attachments[0].body, 'Hello');
|
|
435
|
-
return [2 /*return*/];
|
|
312
|
+
describe('#getAttachmentByTestStepId', () => {
|
|
313
|
+
it('looks up attachments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
314
|
+
const testCases = [];
|
|
315
|
+
yield execute(`Feature: hello
|
|
316
|
+
Scenario: ok
|
|
317
|
+
Given a passed step with attachment
|
|
318
|
+
`, (envelope) => {
|
|
319
|
+
if (envelope.testCase) {
|
|
320
|
+
testCases.push(envelope.testCase);
|
|
436
321
|
}
|
|
437
322
|
});
|
|
438
|
-
|
|
323
|
+
const attachments = cucumberQuery.getTestStepsAttachments([testCases[0].testSteps[0].id]);
|
|
324
|
+
assert_1.default.strictEqual(attachments.length, 1);
|
|
325
|
+
assert_1.default.strictEqual(attachments[0].body, 'Hello');
|
|
326
|
+
}));
|
|
439
327
|
});
|
|
440
328
|
});
|
|
441
|
-
function execute(gherkinSource, messagesHandler) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
return [4 /*yield*/, pipelinePromise(gherkinMessages(gherkinSource, 'test.feature', newId), queryUpdateStream)];
|
|
486
|
-
case 1:
|
|
487
|
-
_a.sent();
|
|
488
|
-
testPlan = fake_cucumber_2.makeTestPlan(gherkinQuery, supportCode, fake_cucumber_2.makeTestCase);
|
|
489
|
-
return [4 /*yield*/, testPlan.execute(function (envelope) {
|
|
490
|
-
messagesHandler(envelope);
|
|
491
|
-
cucumberQuery.update(envelope);
|
|
492
|
-
})];
|
|
493
|
-
case 2:
|
|
494
|
-
_a.sent();
|
|
495
|
-
return [2 /*return*/];
|
|
496
|
-
}
|
|
329
|
+
function execute(gherkinSource, messagesHandler = () => null) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
const newId = messages_1.IdGenerator.incrementing();
|
|
332
|
+
const clock = new fake_cucumber_1.IncrementClock();
|
|
333
|
+
const stopwatch = new fake_cucumber_1.IncrementStopwatch();
|
|
334
|
+
const makeErrorMessage = fake_cucumber_1.withFullStackTrace();
|
|
335
|
+
const supportCode = new fake_cucumber_1.SupportCode(newId, clock, stopwatch, makeErrorMessage);
|
|
336
|
+
supportCode.defineBeforeHook(null, '@beforeHook', () => {
|
|
337
|
+
// no-op
|
|
338
|
+
});
|
|
339
|
+
supportCode.defineAfterHook(null, '@afterHook', () => {
|
|
340
|
+
// no-op
|
|
341
|
+
});
|
|
342
|
+
supportCode.defineStepDefinition(null, 'a passed step', () => {
|
|
343
|
+
// no-op
|
|
344
|
+
});
|
|
345
|
+
supportCode.defineStepDefinition(null, 'a passed step with attachment', function () {
|
|
346
|
+
this.attach('Hello', 'text/plain');
|
|
347
|
+
});
|
|
348
|
+
supportCode.defineStepDefinition(null, 'a failed step', () => {
|
|
349
|
+
throw new Error(`This step failed.`);
|
|
350
|
+
});
|
|
351
|
+
supportCode.defineStepDefinition(null, 'I have {int} cukes in my {word}', (cukes) => {
|
|
352
|
+
assert_1.default.ok(cukes);
|
|
353
|
+
});
|
|
354
|
+
const queryUpdateStream = new stream_1.Writable({
|
|
355
|
+
objectMode: true,
|
|
356
|
+
write(envelope, encoding, callback) {
|
|
357
|
+
try {
|
|
358
|
+
messagesHandler(envelope);
|
|
359
|
+
gherkinQuery.update(envelope);
|
|
360
|
+
cucumberQuery.update(envelope);
|
|
361
|
+
callback();
|
|
362
|
+
}
|
|
363
|
+
catch (err) {
|
|
364
|
+
callback(err);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
yield pipelinePromise(gherkinMessages(gherkinSource, 'test.feature', newId), queryUpdateStream);
|
|
369
|
+
const testPlan = fake_cucumber_1.makeTestPlan(gherkinQuery, supportCode, fake_cucumber_1.makeTestCase);
|
|
370
|
+
yield testPlan.execute((envelope) => {
|
|
371
|
+
messagesHandler(envelope);
|
|
372
|
+
cucumberQuery.update(envelope);
|
|
497
373
|
});
|
|
498
374
|
});
|
|
499
375
|
}
|
|
500
376
|
function gherkinMessages(gherkinSource, uri, newId) {
|
|
501
|
-
|
|
377
|
+
const source = messages_1.messages.Envelope.fromObject({
|
|
502
378
|
source: {
|
|
503
|
-
uri
|
|
379
|
+
uri,
|
|
504
380
|
data: gherkinSource,
|
|
505
381
|
mediaType: 'text/x.cucumber.gherkin+plain',
|
|
506
382
|
},
|
|
507
383
|
});
|
|
508
|
-
return
|
|
384
|
+
return gherkin_streams_1.GherkinStreams.fromSources([source], { newId });
|
|
509
385
|
}
|
|
510
386
|
function findScenario(envelopes) {
|
|
511
|
-
|
|
512
|
-
return gherkinDocument.feature.children.find(
|
|
513
|
-
.scenario;
|
|
387
|
+
const gherkinDocument = envelopes.find((envelope) => envelope.gherkinDocument).gherkinDocument;
|
|
388
|
+
return gherkinDocument.feature.children.find((child) => child.scenario).scenario;
|
|
514
389
|
}
|
|
515
390
|
function findBackground(envelopes) {
|
|
516
|
-
|
|
517
|
-
return gherkinDocument.feature.children.find(
|
|
518
|
-
.background;
|
|
391
|
+
const gherkinDocument = envelopes.find((envelope) => envelope.gherkinDocument).gherkinDocument;
|
|
392
|
+
return gherkinDocument.feature.children.find((child) => child.background).background;
|
|
519
393
|
}
|
|
520
394
|
});
|
|
521
395
|
//# sourceMappingURL=QueryTest.js.map
|