@cucumber/query 5.0.0 → 7.0.1
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/.eslintrc.json +3 -1
- package/.idea/aws.xml +11 -0
- package/.idea/javascript.iml +1 -4
- package/.idea/misc.xml +3 -0
- package/.idea/workspace.xml +36 -285
- package/default.mk +17 -0
- package/dist/src/Query.d.ts +14 -4
- package/dist/src/Query.js +68 -11
- package/dist/src/Query.js.map +1 -1
- package/dist/src/QueryStream.js +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/test/QueryTest.js +285 -56
- package/dist/test/QueryTest.js.map +1 -1
- package/package-lock.json +1281 -1296
- package/package.json +21 -19
- package/src/Query.ts +116 -22
- package/test/QueryTest.ts +334 -50
- package/tsconfig.json +1 -5
- package/.idea/codeStyles/Project.xml +0 -45
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -6
package/test/QueryTest.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import 'source-map-support/register'
|
|
2
|
-
import { GherkinStreams
|
|
2
|
+
import { GherkinStreams } from '@cucumber/gherkin'
|
|
3
|
+
import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
|
|
3
4
|
import { IdGenerator, messages } from '@cucumber/messages'
|
|
4
5
|
import { pipeline, Readable, Writable } from 'stream'
|
|
5
6
|
import assert from 'assert'
|
|
6
|
-
import SupportCode from '@cucumber/fake-cucumber
|
|
7
|
-
import { withFullStackTrace } from '@cucumber/fake-cucumber/dist/src/ErrorMessageGenerator'
|
|
7
|
+
import { SupportCode, withFullStackTrace } from '@cucumber/fake-cucumber'
|
|
8
8
|
|
|
9
9
|
import { promisify } from 'util'
|
|
10
10
|
import IncrementClock from '@cucumber/fake-cucumber/dist/src/IncrementClock'
|
|
11
11
|
import Query from '../src/Query'
|
|
12
|
-
import makeTestPlan from '@cucumber/fake-cucumber
|
|
12
|
+
import { makeTestPlan, makeTestCase } from '@cucumber/fake-cucumber'
|
|
13
|
+
import IncrementStopwatch from '@cucumber/fake-cucumber/dist/src/IncrementStopwatch'
|
|
13
14
|
|
|
14
15
|
const pipelinePromise = promisify(pipeline)
|
|
15
16
|
|
|
@@ -24,17 +25,20 @@ describe('Query', () => {
|
|
|
24
25
|
describe('#getWorstTestStepResult(testStepResults)', () => {
|
|
25
26
|
it('returns a FAILED result for PASSED,FAILED,PASSED', () => {
|
|
26
27
|
const result = cucumberQuery.getWorstTestStepResult([
|
|
27
|
-
new messages.TestStepResult({
|
|
28
|
-
status: messages.TestStepResult.Status.PASSED,
|
|
28
|
+
new messages.TestStepFinished.TestStepResult({
|
|
29
|
+
status: messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
29
30
|
}),
|
|
30
|
-
new messages.TestStepResult({
|
|
31
|
-
status: messages.TestStepResult.Status.FAILED,
|
|
31
|
+
new messages.TestStepFinished.TestStepResult({
|
|
32
|
+
status: messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
32
33
|
}),
|
|
33
|
-
new messages.TestStepResult({
|
|
34
|
-
status: messages.TestStepResult.Status.PASSED,
|
|
34
|
+
new messages.TestStepFinished.TestStepResult({
|
|
35
|
+
status: messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
35
36
|
}),
|
|
36
37
|
])
|
|
37
|
-
assert.strictEqual(
|
|
38
|
+
assert.strictEqual(
|
|
39
|
+
result.status,
|
|
40
|
+
messages.TestStepFinished.TestStepResult.Status.FAILED
|
|
41
|
+
)
|
|
38
42
|
})
|
|
39
43
|
})
|
|
40
44
|
|
|
@@ -43,19 +47,24 @@ describe('Query', () => {
|
|
|
43
47
|
const results = cucumberQuery.getPickleTestStepResults([])
|
|
44
48
|
assert.deepStrictEqual(
|
|
45
49
|
results.map((r) => r.status),
|
|
46
|
-
[messages.TestStepResult.Status.UNKNOWN]
|
|
50
|
+
[messages.TestStepFinished.TestStepResult.Status.UNKNOWN]
|
|
47
51
|
)
|
|
48
52
|
})
|
|
49
53
|
|
|
50
54
|
it('looks up results for scenario steps', async () => {
|
|
55
|
+
const envelopes: messages.IEnvelope[] = []
|
|
56
|
+
|
|
51
57
|
await execute(
|
|
52
58
|
`Feature: hello
|
|
53
59
|
Scenario: ok
|
|
54
60
|
Given a passed step
|
|
55
|
-
|
|
61
|
+
`,
|
|
62
|
+
(envelope) => envelopes.push(envelope)
|
|
56
63
|
)
|
|
57
64
|
|
|
58
|
-
const
|
|
65
|
+
const scenario = findScenario(envelopes)
|
|
66
|
+
|
|
67
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(scenario.steps[0].id)
|
|
59
68
|
assert.strictEqual(pickleStepIds.length, 1)
|
|
60
69
|
|
|
61
70
|
const testStepResults = cucumberQuery.getPickleStepTestStepResults(
|
|
@@ -65,11 +74,13 @@ describe('Query', () => {
|
|
|
65
74
|
|
|
66
75
|
assert.strictEqual(
|
|
67
76
|
testStepResults[0].status,
|
|
68
|
-
messages.TestStepResult.Status.PASSED
|
|
77
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED
|
|
69
78
|
)
|
|
70
79
|
})
|
|
71
80
|
|
|
72
81
|
it('looks up results for background steps', async () => {
|
|
82
|
+
const envelopes: messages.IEnvelope[] = []
|
|
83
|
+
|
|
73
84
|
await execute(
|
|
74
85
|
`Feature: hello
|
|
75
86
|
Background:
|
|
@@ -80,10 +91,14 @@ describe('Query', () => {
|
|
|
80
91
|
|
|
81
92
|
Scenario: ko
|
|
82
93
|
Given a failed step
|
|
83
|
-
|
|
94
|
+
`,
|
|
95
|
+
(envelope) => envelopes.push(envelope)
|
|
84
96
|
)
|
|
85
97
|
|
|
86
|
-
const
|
|
98
|
+
const background = findBackground(envelopes)
|
|
99
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(
|
|
100
|
+
background.steps[0].id
|
|
101
|
+
)
|
|
87
102
|
assert.strictEqual(pickleStepIds.length, 2)
|
|
88
103
|
|
|
89
104
|
const testStepResults = cucumberQuery.getPickleStepTestStepResults(
|
|
@@ -93,25 +108,31 @@ describe('Query', () => {
|
|
|
93
108
|
assert.deepStrictEqual(
|
|
94
109
|
testStepResults.map((r) => r.status),
|
|
95
110
|
[
|
|
96
|
-
messages.TestStepResult.Status.PASSED,
|
|
97
|
-
messages.TestStepResult.Status.PASSED,
|
|
111
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
112
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
98
113
|
]
|
|
99
114
|
)
|
|
100
115
|
})
|
|
101
116
|
|
|
102
117
|
it('looks up results for background steps when scenarios are empty', async () => {
|
|
118
|
+
const envelopes: messages.IEnvelope[] = []
|
|
119
|
+
|
|
103
120
|
await execute(
|
|
104
121
|
`Feature: hello
|
|
105
122
|
Background:
|
|
106
|
-
|
|
123
|
+
Given a passed step
|
|
107
124
|
|
|
108
125
|
Scenario: ok
|
|
109
126
|
|
|
110
127
|
Scenario: ok too
|
|
111
|
-
|
|
128
|
+
`,
|
|
129
|
+
(envelope) => envelopes.push(envelope)
|
|
112
130
|
)
|
|
113
131
|
|
|
114
|
-
const
|
|
132
|
+
const background = findBackground(envelopes)
|
|
133
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(
|
|
134
|
+
background.steps[0].id
|
|
135
|
+
)
|
|
115
136
|
assert.strictEqual(pickleStepIds.length, 0)
|
|
116
137
|
|
|
117
138
|
const testStepResults = cucumberQuery.getPickleStepTestStepResults(
|
|
@@ -121,22 +142,25 @@ describe('Query', () => {
|
|
|
121
142
|
|
|
122
143
|
assert.strictEqual(
|
|
123
144
|
testStepResults[0].status,
|
|
124
|
-
messages.TestStepResult.Status.UNKNOWN
|
|
145
|
+
messages.TestStepFinished.TestStepResult.Status.UNKNOWN
|
|
125
146
|
)
|
|
126
147
|
})
|
|
127
148
|
})
|
|
128
149
|
|
|
129
150
|
describe('#getPickleTestStepResults(pickleIds)', () => {
|
|
130
151
|
it('looks up results for scenarios', async () => {
|
|
152
|
+
const envelopes: messages.IEnvelope[] = []
|
|
131
153
|
await execute(
|
|
132
154
|
`Feature: hello
|
|
133
155
|
Scenario: ko
|
|
134
156
|
Given a passed step
|
|
135
157
|
Given a failed step
|
|
136
|
-
|
|
158
|
+
`,
|
|
159
|
+
(envelope) => envelopes.push(envelope)
|
|
137
160
|
)
|
|
138
161
|
|
|
139
|
-
const
|
|
162
|
+
const scenario = findScenario(envelopes)
|
|
163
|
+
const pickleIds = gherkinQuery.getPickleIds('test.feature', scenario.id)
|
|
140
164
|
assert.strictEqual(pickleIds.length, 1)
|
|
141
165
|
|
|
142
166
|
const testStepResults = cucumberQuery.getPickleTestStepResults(pickleIds)
|
|
@@ -144,13 +168,14 @@ describe('Query', () => {
|
|
|
144
168
|
assert.deepStrictEqual(
|
|
145
169
|
testStepResults.map((r) => r.status),
|
|
146
170
|
[
|
|
147
|
-
messages.TestStepResult.Status.PASSED,
|
|
148
|
-
messages.TestStepResult.Status.FAILED,
|
|
171
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
172
|
+
messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
149
173
|
]
|
|
150
174
|
)
|
|
151
175
|
})
|
|
152
176
|
|
|
153
177
|
it('looks up results for scenario outlines', async () => {
|
|
178
|
+
const envelopes: messages.IEnvelope[] = []
|
|
154
179
|
await execute(
|
|
155
180
|
`Feature: hello
|
|
156
181
|
Scenario: hi <status1> and <status2>
|
|
@@ -161,23 +186,28 @@ describe('Query', () => {
|
|
|
161
186
|
| status1 | status2 |
|
|
162
187
|
| passed | passed |
|
|
163
188
|
| passed | failed |
|
|
164
|
-
|
|
189
|
+
`,
|
|
190
|
+
(envelope) => envelopes.push(envelope)
|
|
165
191
|
)
|
|
166
|
-
|
|
192
|
+
|
|
193
|
+
const scenario = findScenario(envelopes)
|
|
194
|
+
const pickleIds = gherkinQuery.getPickleIds('test.feature', scenario.id)
|
|
167
195
|
assert.strictEqual(pickleIds.length, 2)
|
|
168
196
|
|
|
169
197
|
assert.deepStrictEqual(
|
|
170
198
|
cucumberQuery.getPickleTestStepResults(pickleIds).map((r) => r.status),
|
|
171
199
|
[
|
|
172
|
-
messages.TestStepResult.Status.PASSED,
|
|
173
|
-
messages.TestStepResult.Status.PASSED,
|
|
174
|
-
messages.TestStepResult.Status.PASSED,
|
|
175
|
-
messages.TestStepResult.Status.FAILED,
|
|
200
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
201
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
202
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
203
|
+
messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
176
204
|
]
|
|
177
205
|
)
|
|
178
206
|
})
|
|
179
207
|
|
|
180
208
|
it('looks up results for examples rows outlines', async () => {
|
|
209
|
+
const envelopes: messages.IEnvelope[] = []
|
|
210
|
+
|
|
181
211
|
await execute(
|
|
182
212
|
`Feature: hello
|
|
183
213
|
Scenario: hi <status1> and <status2>
|
|
@@ -188,30 +218,34 @@ describe('Query', () => {
|
|
|
188
218
|
| status1 | status2 |
|
|
189
219
|
| passed | passed |
|
|
190
220
|
| passed | failed |
|
|
191
|
-
|
|
221
|
+
`,
|
|
222
|
+
(envelope) => envelopes.push(envelope)
|
|
192
223
|
)
|
|
193
224
|
|
|
225
|
+
const scenario = findScenario(envelopes)
|
|
226
|
+
const exampleIds = scenario.examples[0].tableBody.map((row) => row.id)
|
|
227
|
+
|
|
194
228
|
assert.deepStrictEqual(
|
|
195
229
|
cucumberQuery
|
|
196
230
|
.getPickleTestStepResults(
|
|
197
|
-
gherkinQuery.getPickleIds('test.feature',
|
|
231
|
+
gherkinQuery.getPickleIds('test.feature', exampleIds[0])
|
|
198
232
|
)
|
|
199
233
|
.map((r) => r.status),
|
|
200
234
|
[
|
|
201
|
-
messages.TestStepResult.Status.PASSED,
|
|
202
|
-
messages.TestStepResult.Status.PASSED,
|
|
235
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
236
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
203
237
|
]
|
|
204
238
|
)
|
|
205
239
|
|
|
206
240
|
assert.deepStrictEqual(
|
|
207
241
|
cucumberQuery
|
|
208
242
|
.getPickleTestStepResults(
|
|
209
|
-
gherkinQuery.getPickleIds('test.feature',
|
|
243
|
+
gherkinQuery.getPickleIds('test.feature', exampleIds[1])
|
|
210
244
|
)
|
|
211
245
|
.map((r) => r.status),
|
|
212
246
|
[
|
|
213
|
-
messages.TestStepResult.Status.PASSED,
|
|
214
|
-
messages.TestStepResult.Status.FAILED,
|
|
247
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED,
|
|
248
|
+
messages.TestStepFinished.TestStepResult.Status.FAILED,
|
|
215
249
|
]
|
|
216
250
|
)
|
|
217
251
|
})
|
|
@@ -219,14 +253,17 @@ describe('Query', () => {
|
|
|
219
253
|
|
|
220
254
|
describe('#getPickleStepAttachments(pickleIds)', () => {
|
|
221
255
|
it('looks up attachments', async () => {
|
|
256
|
+
const envelopes: messages.IEnvelope[] = []
|
|
222
257
|
await execute(
|
|
223
258
|
`Feature: hello
|
|
224
259
|
Scenario: ok
|
|
225
260
|
Given a passed step with attachment
|
|
226
|
-
|
|
261
|
+
`,
|
|
262
|
+
(envelope) => envelopes.push(envelope)
|
|
227
263
|
)
|
|
228
264
|
|
|
229
|
-
const
|
|
265
|
+
const scenario = findScenario(envelopes)
|
|
266
|
+
const pickleStepIds = gherkinQuery.getPickleStepIds(scenario.steps[0].id)
|
|
230
267
|
assert.strictEqual(pickleStepIds.length, 1)
|
|
231
268
|
|
|
232
269
|
const attachments = cucumberQuery.getPickleStepAttachments(pickleStepIds)
|
|
@@ -238,18 +275,22 @@ describe('Query', () => {
|
|
|
238
275
|
|
|
239
276
|
describe('#getStepMatchArguments(uri, lineNumber)', () => {
|
|
240
277
|
it("looks up result for step's uri and line", async () => {
|
|
278
|
+
const envelopes: messages.IEnvelope[] = []
|
|
241
279
|
await execute(
|
|
242
280
|
`Feature: hello
|
|
243
|
-
Scenario:
|
|
281
|
+
Scenario: ok
|
|
244
282
|
Given a passed step
|
|
245
283
|
And I have 567 cukes in my belly
|
|
246
|
-
|
|
284
|
+
`,
|
|
285
|
+
(envelope) => envelopes.push(envelope)
|
|
247
286
|
)
|
|
248
287
|
|
|
288
|
+
const scenario = findScenario(envelopes)
|
|
289
|
+
|
|
249
290
|
assert.deepStrictEqual(
|
|
250
291
|
cucumberQuery
|
|
251
292
|
.getStepMatchArgumentsLists(
|
|
252
|
-
gherkinQuery.getPickleStepIds(
|
|
293
|
+
gherkinQuery.getPickleStepIds(scenario.steps[0].id)[0]
|
|
253
294
|
)
|
|
254
295
|
.map((sal) =>
|
|
255
296
|
sal.stepMatchArguments.map((arg) => arg.parameterTypeName)
|
|
@@ -260,7 +301,7 @@ describe('Query', () => {
|
|
|
260
301
|
assert.deepStrictEqual(
|
|
261
302
|
cucumberQuery
|
|
262
303
|
.getStepMatchArgumentsLists(
|
|
263
|
-
gherkinQuery.getPickleStepIds(
|
|
304
|
+
gherkinQuery.getPickleStepIds(scenario.steps[1].id)[0]
|
|
264
305
|
)
|
|
265
306
|
.map((sal) =>
|
|
266
307
|
sal.stepMatchArguments.map((arg) => arg.parameterTypeName)
|
|
@@ -268,13 +309,232 @@ describe('Query', () => {
|
|
|
268
309
|
[['int', 'word']]
|
|
269
310
|
)
|
|
270
311
|
})
|
|
312
|
+
|
|
313
|
+
describe('#getBeforeHookSteps(pickleId: string)', () => {
|
|
314
|
+
it('returns an empty list when there is no hooks', async () => {
|
|
315
|
+
const envelopes: messages.IEnvelope[] = []
|
|
316
|
+
await execute(
|
|
317
|
+
`Feature: hello
|
|
318
|
+
Scenario: hi
|
|
319
|
+
Given a passed step
|
|
320
|
+
`,
|
|
321
|
+
(envelope) => envelopes.push(envelope)
|
|
322
|
+
)
|
|
323
|
+
const scenarioId = findScenario(envelopes).id
|
|
324
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
325
|
+
'test.feature',
|
|
326
|
+
scenarioId
|
|
327
|
+
)[0]
|
|
328
|
+
|
|
329
|
+
assert.deepStrictEqual(cucumberQuery.getBeforeHookSteps(pickleId), [])
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('returns one before hook step', async () => {
|
|
333
|
+
const envelopes: messages.IEnvelope[] = []
|
|
334
|
+
await execute(
|
|
335
|
+
`Feature: hello
|
|
336
|
+
@beforeHook
|
|
337
|
+
Scenario: hi
|
|
338
|
+
Given a passed step
|
|
339
|
+
`,
|
|
340
|
+
(envelope) => envelopes.push(envelope)
|
|
341
|
+
)
|
|
342
|
+
const scenarioId = findScenario(envelopes).id
|
|
343
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
344
|
+
'test.feature',
|
|
345
|
+
scenarioId
|
|
346
|
+
)[0]
|
|
347
|
+
|
|
348
|
+
assert.strictEqual(cucumberQuery.getBeforeHookSteps(pickleId).length, 1)
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
it('does not return after hook steps', async () => {
|
|
352
|
+
const envelopes: messages.IEnvelope[] = []
|
|
353
|
+
await execute(
|
|
354
|
+
`Feature: hello
|
|
355
|
+
@afterHook
|
|
356
|
+
Scenario: hi
|
|
357
|
+
Given a passed step
|
|
358
|
+
`,
|
|
359
|
+
(envelope) => envelopes.push(envelope)
|
|
360
|
+
)
|
|
361
|
+
const scenarioId = findScenario(envelopes).id
|
|
362
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
363
|
+
'test.feature',
|
|
364
|
+
scenarioId
|
|
365
|
+
)[0]
|
|
366
|
+
|
|
367
|
+
assert.deepStrictEqual(cucumberQuery.getBeforeHookSteps(pickleId), [])
|
|
368
|
+
})
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
describe('#getAfterHookSteps(pickleId: string)', () => {
|
|
372
|
+
it('returns an empty list when there is no hooks', async () => {
|
|
373
|
+
const envelopes: messages.IEnvelope[] = []
|
|
374
|
+
await execute(
|
|
375
|
+
`Feature: hello
|
|
376
|
+
Scenario: hi
|
|
377
|
+
Given a passed step
|
|
378
|
+
`,
|
|
379
|
+
(envelope) => envelopes.push(envelope)
|
|
380
|
+
)
|
|
381
|
+
const scenarioId = findScenario(envelopes).id
|
|
382
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
383
|
+
'test.feature',
|
|
384
|
+
scenarioId
|
|
385
|
+
)[0]
|
|
386
|
+
|
|
387
|
+
assert.deepStrictEqual(cucumberQuery.getAfterHookSteps(pickleId), [])
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
it('returns one after hook step', async () => {
|
|
391
|
+
const envelopes: messages.IEnvelope[] = []
|
|
392
|
+
await execute(
|
|
393
|
+
`Feature: hello
|
|
394
|
+
@afterHook
|
|
395
|
+
Scenario: hi
|
|
396
|
+
Given a passed step
|
|
397
|
+
`,
|
|
398
|
+
(envelope) => envelopes.push(envelope)
|
|
399
|
+
)
|
|
400
|
+
const scenarioId = findScenario(envelopes).id
|
|
401
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
402
|
+
'test.feature',
|
|
403
|
+
scenarioId
|
|
404
|
+
)[0]
|
|
405
|
+
|
|
406
|
+
assert.strictEqual(cucumberQuery.getAfterHookSteps(pickleId).length, 1)
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
it('does not return before hook steps', async () => {
|
|
410
|
+
const envelopes: messages.IEnvelope[] = []
|
|
411
|
+
await execute(
|
|
412
|
+
`Feature: hello
|
|
413
|
+
@beforeHook
|
|
414
|
+
Scenario: hi
|
|
415
|
+
Given a passed step
|
|
416
|
+
`,
|
|
417
|
+
(envelope) => envelopes.push(envelope)
|
|
418
|
+
)
|
|
419
|
+
const scenarioId = findScenario(envelopes).id
|
|
420
|
+
const pickleId = gherkinQuery.getPickleIds(
|
|
421
|
+
'test.feature',
|
|
422
|
+
scenarioId
|
|
423
|
+
)[0]
|
|
424
|
+
|
|
425
|
+
assert.deepStrictEqual(cucumberQuery.getAfterHookSteps(pickleId), [])
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
describe('#getTestStepResult', () => {
|
|
430
|
+
it('returns one test step result', async () => {
|
|
431
|
+
const emittedMessages: Array<messages.IEnvelope> = []
|
|
432
|
+
await execute(
|
|
433
|
+
`Feature: hello
|
|
434
|
+
Scenario: hi
|
|
435
|
+
Given a passed step
|
|
436
|
+
`,
|
|
437
|
+
(message) => emittedMessages.push(message)
|
|
438
|
+
)
|
|
439
|
+
const testCase = emittedMessages.find((child) => child.testCase)
|
|
440
|
+
.testCase
|
|
441
|
+
const testStep = testCase.testSteps[0]
|
|
442
|
+
const results = cucumberQuery.getTestStepResults(testStep.id)
|
|
443
|
+
|
|
444
|
+
assert.deepStrictEqual(results.length, 1)
|
|
445
|
+
assert.deepStrictEqual(
|
|
446
|
+
results[0].status,
|
|
447
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED
|
|
448
|
+
)
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it('returns a result for hook step', async () => {
|
|
452
|
+
const emittedMessages: Array<messages.IEnvelope> = []
|
|
453
|
+
await execute(
|
|
454
|
+
`Feature: hello
|
|
455
|
+
@beforeHook
|
|
456
|
+
Scenario: hi
|
|
457
|
+
Given a passed step
|
|
458
|
+
`,
|
|
459
|
+
(message) => emittedMessages.push(message)
|
|
460
|
+
)
|
|
461
|
+
const testCase = emittedMessages.find((child) => child.testCase)
|
|
462
|
+
.testCase
|
|
463
|
+
const testStep = testCase.testSteps[0]
|
|
464
|
+
const results = cucumberQuery.getTestStepResults(testStep.id)
|
|
465
|
+
|
|
466
|
+
assert.deepStrictEqual(results.length, 1)
|
|
467
|
+
assert.deepStrictEqual(
|
|
468
|
+
results[0].status,
|
|
469
|
+
messages.TestStepFinished.TestStepResult.Status.PASSED
|
|
470
|
+
)
|
|
471
|
+
})
|
|
472
|
+
})
|
|
473
|
+
|
|
474
|
+
describe('#getHook(HookId)', () => {
|
|
475
|
+
it('returns undefined if the id does not match any hook', () => {
|
|
476
|
+
assert.strictEqual(cucumberQuery.getHook('tralala'), undefined)
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
it('returns the matching hook', () => {
|
|
480
|
+
const hook = messages.Hook.create({
|
|
481
|
+
id: 'tralala',
|
|
482
|
+
})
|
|
483
|
+
const envelope = messages.Envelope.create({
|
|
484
|
+
hook,
|
|
485
|
+
})
|
|
486
|
+
|
|
487
|
+
cucumberQuery.update(envelope)
|
|
488
|
+
|
|
489
|
+
assert.deepStrictEqual(cucumberQuery.getHook('tralala'), hook)
|
|
490
|
+
})
|
|
491
|
+
})
|
|
492
|
+
|
|
493
|
+
describe('#getAttachmentByTestStepId', () => {
|
|
494
|
+
it('looks up attachments', async () => {
|
|
495
|
+
const testCases: messages.ITestCase[] = []
|
|
496
|
+
await execute(
|
|
497
|
+
`Feature: hello
|
|
498
|
+
Scenario: ok
|
|
499
|
+
Given a passed step with attachment
|
|
500
|
+
`,
|
|
501
|
+
(envelope) => {
|
|
502
|
+
if (envelope.testCase) {
|
|
503
|
+
testCases.push(envelope.testCase)
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
const attachments = cucumberQuery.getTestStepsAttachments([
|
|
509
|
+
testCases[0].testSteps[0].id,
|
|
510
|
+
])
|
|
511
|
+
assert.strictEqual(attachments.length, 1)
|
|
512
|
+
|
|
513
|
+
assert.strictEqual(attachments[0].body, 'Hello')
|
|
514
|
+
})
|
|
515
|
+
})
|
|
271
516
|
})
|
|
272
517
|
|
|
273
|
-
async function execute(
|
|
518
|
+
async function execute(
|
|
519
|
+
gherkinSource: string,
|
|
520
|
+
messagesHandler: (envelope: messages.IEnvelope) => void = () => null
|
|
521
|
+
): Promise<void> {
|
|
274
522
|
const newId = IdGenerator.incrementing()
|
|
275
523
|
const clock = new IncrementClock()
|
|
524
|
+
const stopwatch = new IncrementStopwatch()
|
|
276
525
|
const makeErrorMessage = withFullStackTrace()
|
|
277
|
-
const supportCode = new SupportCode(
|
|
526
|
+
const supportCode = new SupportCode(
|
|
527
|
+
newId,
|
|
528
|
+
clock,
|
|
529
|
+
stopwatch,
|
|
530
|
+
makeErrorMessage
|
|
531
|
+
)
|
|
532
|
+
supportCode.defineBeforeHook(null, '@beforeHook', () => {
|
|
533
|
+
// no-op
|
|
534
|
+
})
|
|
535
|
+
supportCode.defineAfterHook(null, '@afterHook', () => {
|
|
536
|
+
// no-op
|
|
537
|
+
})
|
|
278
538
|
supportCode.defineStepDefinition(null, 'a passed step', () => {
|
|
279
539
|
// no-op
|
|
280
540
|
})
|
|
@@ -304,6 +564,7 @@ describe('Query', () => {
|
|
|
304
564
|
callback: (error?: Error | null) => void
|
|
305
565
|
): void {
|
|
306
566
|
try {
|
|
567
|
+
messagesHandler(envelope)
|
|
307
568
|
gherkinQuery.update(envelope)
|
|
308
569
|
cucumberQuery.update(envelope)
|
|
309
570
|
callback()
|
|
@@ -317,8 +578,11 @@ describe('Query', () => {
|
|
|
317
578
|
queryUpdateStream
|
|
318
579
|
)
|
|
319
580
|
|
|
320
|
-
const testPlan = makeTestPlan(gherkinQuery, supportCode)
|
|
321
|
-
await testPlan.execute((envelope) =>
|
|
581
|
+
const testPlan = makeTestPlan(gherkinQuery, supportCode, makeTestCase)
|
|
582
|
+
await testPlan.execute((envelope: messages.IEnvelope) => {
|
|
583
|
+
messagesHandler(envelope)
|
|
584
|
+
cucumberQuery.update(envelope)
|
|
585
|
+
})
|
|
322
586
|
}
|
|
323
587
|
|
|
324
588
|
function gherkinMessages(
|
|
@@ -335,4 +599,24 @@ describe('Query', () => {
|
|
|
335
599
|
})
|
|
336
600
|
return GherkinStreams.fromSources([source], { newId })
|
|
337
601
|
}
|
|
602
|
+
|
|
603
|
+
function findScenario(
|
|
604
|
+
envelopes: messages.IEnvelope[]
|
|
605
|
+
): messages.GherkinDocument.Feature.IScenario {
|
|
606
|
+
const gherkinDocument = envelopes.find(
|
|
607
|
+
(envelope) => envelope.gherkinDocument
|
|
608
|
+
).gherkinDocument
|
|
609
|
+
return gherkinDocument.feature.children.find((child) => child.scenario)
|
|
610
|
+
.scenario
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function findBackground(
|
|
614
|
+
envelopes: messages.IEnvelope[]
|
|
615
|
+
): messages.GherkinDocument.Feature.IBackground {
|
|
616
|
+
const gherkinDocument = envelopes.find(
|
|
617
|
+
(envelope) => envelope.gherkinDocument
|
|
618
|
+
).gherkinDocument
|
|
619
|
+
return gherkinDocument.feature.children.find((child) => child.background)
|
|
620
|
+
.background
|
|
621
|
+
}
|
|
338
622
|
})
|
package/tsconfig.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
-
<code_scheme name="Project" version="173">
|
|
3
|
-
<option name="AUTODETECT_INDENTS" value="false" />
|
|
4
|
-
<JSCodeStyleSettings version="0">
|
|
5
|
-
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
6
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
7
|
-
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
8
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
9
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
10
|
-
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
11
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
12
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
13
|
-
</JSCodeStyleSettings>
|
|
14
|
-
<JavaCodeStyleSettings>
|
|
15
|
-
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="500" />
|
|
16
|
-
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="300" />
|
|
17
|
-
</JavaCodeStyleSettings>
|
|
18
|
-
<TypeScriptCodeStyleSettings version="0">
|
|
19
|
-
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
|
20
|
-
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
21
|
-
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
22
|
-
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
23
|
-
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
24
|
-
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
25
|
-
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
26
|
-
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
27
|
-
</TypeScriptCodeStyleSettings>
|
|
28
|
-
<codeStyleSettings language="JavaScript">
|
|
29
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
30
|
-
<indentOptions>
|
|
31
|
-
<option name="INDENT_SIZE" value="2" />
|
|
32
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
33
|
-
<option name="TAB_SIZE" value="2" />
|
|
34
|
-
</indentOptions>
|
|
35
|
-
</codeStyleSettings>
|
|
36
|
-
<codeStyleSettings language="TypeScript">
|
|
37
|
-
<option name="SOFT_MARGINS" value="80" />
|
|
38
|
-
<indentOptions>
|
|
39
|
-
<option name="INDENT_SIZE" value="2" />
|
|
40
|
-
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
41
|
-
<option name="TAB_SIZE" value="2" />
|
|
42
|
-
</indentOptions>
|
|
43
|
-
</codeStyleSettings>
|
|
44
|
-
</code_scheme>
|
|
45
|
-
</component>
|