@autometa/jest-executor 0.6.4 → 1.0.0-rc.3
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/README.md +1 -1
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +13 -15
- package/dist/index.js +28 -971
- package/dist/index.js.map +1 -1
- package/package.json +33 -37
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -4
- package/.turbo/turbo-lint$colon$fix.log +0 -4
- package/.turbo/turbo-prettify.log +0 -0
- package/.turbo/turbo-test.log +0 -15
- package/CHANGELOG.md +0 -777
- package/dist/esm/index.js +0 -972
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.cts +0 -15
- package/tsup.config.ts +0 -14
package/dist/esm/index.js
DELETED
|
@@ -1,972 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/executor.ts
|
|
10
|
-
import {
|
|
11
|
-
ScenarioOutlineBridge,
|
|
12
|
-
find,
|
|
13
|
-
GlobalBridge
|
|
14
|
-
} from "@autometa/test-builder";
|
|
15
|
-
import {
|
|
16
|
-
describe,
|
|
17
|
-
it,
|
|
18
|
-
expect,
|
|
19
|
-
beforeEach,
|
|
20
|
-
afterEach,
|
|
21
|
-
afterAll,
|
|
22
|
-
beforeAll,
|
|
23
|
-
jest
|
|
24
|
-
} from "@jest/globals";
|
|
25
|
-
import { AutomationError, formatErrorCauses, raise } from "@autometa/errors";
|
|
26
|
-
import { Query } from "@autometa/test-builder";
|
|
27
|
-
|
|
28
|
-
// src/timeout-selector.ts
|
|
29
|
-
import { NullTimeout, Timeout } from "@autometa/scopes";
|
|
30
|
-
function getTimeout(target, config) {
|
|
31
|
-
if (target && !(target instanceof NullTimeout)) {
|
|
32
|
-
return target;
|
|
33
|
-
}
|
|
34
|
-
return Timeout.from(config?.current?.test?.timeout);
|
|
35
|
-
}
|
|
36
|
-
function chooseTimeout(timeout1, timeout2) {
|
|
37
|
-
if (timeout2 instanceof Timeout && !(timeout2 instanceof NullTimeout)) {
|
|
38
|
-
return {
|
|
39
|
-
getTimeout: getTimeout.bind(null, timeout2)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (timeout1 instanceof Timeout && !(timeout1 instanceof NullTimeout)) {
|
|
43
|
-
return {
|
|
44
|
-
getTimeout: getTimeout.bind(null, timeout1)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
getTimeout: getTimeout.bind(null, Timeout.from(0))
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/executor.ts
|
|
53
|
-
import { NullTimeout as NullTimeout2, Timeout as Timeout2 } from "@autometa/scopes";
|
|
54
|
-
import { Container, defineContainerContext } from "@autometa/injection";
|
|
55
|
-
import { isTagsMatch } from "@autometa/gherkin";
|
|
56
|
-
var outlineApps = /* @__PURE__ */ new Map();
|
|
57
|
-
var examplesApps = /* @__PURE__ */ new Map();
|
|
58
|
-
var featureApps = /* @__PURE__ */ new Map();
|
|
59
|
-
var ruleApps = /* @__PURE__ */ new Map();
|
|
60
|
-
function execute({ app, world }, global, bridge, events, config) {
|
|
61
|
-
const globalBridge = new GlobalBridge(global);
|
|
62
|
-
const featureTitle = bridge.data.scope.title(bridge.data.gherkin);
|
|
63
|
-
const [group, modifier] = getGroupOrModifier(bridge);
|
|
64
|
-
const chosenTimeout = chooseTimeout(
|
|
65
|
-
new NullTimeout2(),
|
|
66
|
-
bridge.data.scope.timeout
|
|
67
|
-
).getTimeout(config);
|
|
68
|
-
beforeAll(() => {
|
|
69
|
-
events.feature.emitStart({
|
|
70
|
-
title: featureTitle,
|
|
71
|
-
path: bridge.data.scope.path,
|
|
72
|
-
modifier,
|
|
73
|
-
tags: [...bridge.data.gherkin.tags]
|
|
74
|
-
});
|
|
75
|
-
}, chosenTimeout.milliseconds);
|
|
76
|
-
group(featureTitle, () => {
|
|
77
|
-
const tags = [...bridge.data.gherkin.tags];
|
|
78
|
-
const retries = tags.find((tag) => tag.startsWith("@retries="));
|
|
79
|
-
let testContainerContext;
|
|
80
|
-
let testContainer;
|
|
81
|
-
let localApp;
|
|
82
|
-
const globalContainerContext = defineContainerContext("global");
|
|
83
|
-
const globalContainer = new Container(globalContainerContext);
|
|
84
|
-
globalContainer.registerCached(world);
|
|
85
|
-
const staticApp = globalContainer.get(app);
|
|
86
|
-
staticApp.world = globalContainer.get(world);
|
|
87
|
-
staticApp.di = globalContainer;
|
|
88
|
-
beforeAll(() => {
|
|
89
|
-
if (retries) {
|
|
90
|
-
const count = parseInt(retries.split("=")[1]);
|
|
91
|
-
jest.retryTimes(count);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
beforeEach(() => {
|
|
95
|
-
const name = expect.getState().currentTestName ?? raise("A test must have a name");
|
|
96
|
-
testContainerContext = defineContainerContext(name);
|
|
97
|
-
testContainer = new Container(testContainerContext);
|
|
98
|
-
testContainer.registerCached(world);
|
|
99
|
-
localApp = testContainer.get(app);
|
|
100
|
-
localApp.world = testContainer.get(world);
|
|
101
|
-
localApp.di = testContainer;
|
|
102
|
-
if (!featureApps.has(name)) {
|
|
103
|
-
featureApps.set(name, []);
|
|
104
|
-
}
|
|
105
|
-
featureApps.get(name)?.push(localApp);
|
|
106
|
-
});
|
|
107
|
-
bridge.data.scope.hooks.beforeFeatureHooks.forEach((hook) => {
|
|
108
|
-
const hookTimeout = chooseTimeout(
|
|
109
|
-
chosenTimeout,
|
|
110
|
-
hook.options.timeout
|
|
111
|
-
).getTimeout(config).milliseconds;
|
|
112
|
-
beforeAll(async () => {
|
|
113
|
-
const tags2 = bridge?.data?.gherkin?.tags ?? [];
|
|
114
|
-
if (!hook.canExecute(...tags2)) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
events.beforeFeature.emitStart({
|
|
118
|
-
title: hook.description,
|
|
119
|
-
tags: [...tags2]
|
|
120
|
-
});
|
|
121
|
-
const report = await hook.execute(staticApp, ...tags2);
|
|
122
|
-
if (report.error) {
|
|
123
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
124
|
-
events.beforeFeature.emitEnd({
|
|
125
|
-
title: hook.description,
|
|
126
|
-
tags: [...tags2],
|
|
127
|
-
status: "FAILED",
|
|
128
|
-
error: report.error
|
|
129
|
-
});
|
|
130
|
-
throw new AutomationError(message, { cause: report.error });
|
|
131
|
-
}
|
|
132
|
-
events.beforeFeature.emitEnd({
|
|
133
|
-
title: hook.description,
|
|
134
|
-
tags: [...tags2],
|
|
135
|
-
status: "PASSED"
|
|
136
|
-
});
|
|
137
|
-
}, hookTimeout);
|
|
138
|
-
});
|
|
139
|
-
bridge.data.scope.hooks.afterFeatureHooks.forEach((hook) => {
|
|
140
|
-
const hookTimeout = chooseTimeout(
|
|
141
|
-
chosenTimeout,
|
|
142
|
-
hook.options.timeout
|
|
143
|
-
).getTimeout(config).milliseconds;
|
|
144
|
-
afterAll(async () => {
|
|
145
|
-
const tags2 = bridge?.data?.gherkin?.tags ?? [];
|
|
146
|
-
if (!hook.canExecute(...bridge.data.gherkin.tags)) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
events.afterFeature.emitStart({
|
|
150
|
-
title: hook.description,
|
|
151
|
-
tags: [...tags2]
|
|
152
|
-
});
|
|
153
|
-
const testName = expect.getState().currentTestName;
|
|
154
|
-
const apps = featureApps.get(testName);
|
|
155
|
-
const report = await hook.execute(staticApp, apps, ...tags2);
|
|
156
|
-
if (report.error) {
|
|
157
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
158
|
-
events.afterFeature.emitEnd({
|
|
159
|
-
title: hook.description,
|
|
160
|
-
tags: [...tags2],
|
|
161
|
-
status: "FAILED",
|
|
162
|
-
error: report.error
|
|
163
|
-
});
|
|
164
|
-
throw new AutomationError(message, { cause: report.error });
|
|
165
|
-
}
|
|
166
|
-
events.afterFeature.emitEnd({
|
|
167
|
-
title: hook.description,
|
|
168
|
-
tags: [...tags2],
|
|
169
|
-
status: "PASSED"
|
|
170
|
-
});
|
|
171
|
-
}, hookTimeout);
|
|
172
|
-
});
|
|
173
|
-
bootstrapSetupHooks(globalBridge, staticApp, events, [
|
|
174
|
-
config,
|
|
175
|
-
chosenTimeout
|
|
176
|
-
]);
|
|
177
|
-
bootstrapSetupHooks(bridge, staticApp, events, [config, chosenTimeout]);
|
|
178
|
-
bootstrapBeforeHooks(
|
|
179
|
-
bridge,
|
|
180
|
-
globalBridge,
|
|
181
|
-
() => [testContainer, localApp],
|
|
182
|
-
events,
|
|
183
|
-
[config, chosenTimeout]
|
|
184
|
-
);
|
|
185
|
-
bootstrapBeforeHooks(
|
|
186
|
-
bridge,
|
|
187
|
-
bridge,
|
|
188
|
-
() => [testContainer, localApp],
|
|
189
|
-
events,
|
|
190
|
-
[config, chosenTimeout]
|
|
191
|
-
);
|
|
192
|
-
bootstrapBackground(
|
|
193
|
-
bridge,
|
|
194
|
-
bridge,
|
|
195
|
-
() => [testContainer, localApp],
|
|
196
|
-
events,
|
|
197
|
-
[config, chosenTimeout]
|
|
198
|
-
);
|
|
199
|
-
bootstrapScenarios(
|
|
200
|
-
bridge,
|
|
201
|
-
bridge,
|
|
202
|
-
() => [testContainer, localApp],
|
|
203
|
-
staticApp,
|
|
204
|
-
events,
|
|
205
|
-
[config, chosenTimeout]
|
|
206
|
-
);
|
|
207
|
-
bootstrapRules(bridge, () => [testContainer, localApp], staticApp, events, [
|
|
208
|
-
config,
|
|
209
|
-
chosenTimeout
|
|
210
|
-
]);
|
|
211
|
-
bootstrapAfterHooks(
|
|
212
|
-
bridge,
|
|
213
|
-
bridge,
|
|
214
|
-
() => [testContainer, localApp],
|
|
215
|
-
events,
|
|
216
|
-
[config, chosenTimeout]
|
|
217
|
-
);
|
|
218
|
-
bootstrapAfterHooks(
|
|
219
|
-
bridge,
|
|
220
|
-
globalBridge,
|
|
221
|
-
() => [testContainer, localApp],
|
|
222
|
-
events,
|
|
223
|
-
[config, chosenTimeout]
|
|
224
|
-
);
|
|
225
|
-
bootstrapTeardownHooks(globalBridge, staticApp, events, [
|
|
226
|
-
config,
|
|
227
|
-
chosenTimeout
|
|
228
|
-
]);
|
|
229
|
-
bootstrapTeardownHooks(bridge, staticApp, events, [config, chosenTimeout]);
|
|
230
|
-
afterAll(async () => {
|
|
231
|
-
await globalContainer.disposeGlobal(tags, isTagsMatch);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
afterAll(async () => {
|
|
235
|
-
const failures = Query.find.failed(bridge);
|
|
236
|
-
const status = modifier === "skip" ? "SKIPPED" : failures.length === 0 ? "PASSED" : "FAILED";
|
|
237
|
-
events.feature.emitEnd({
|
|
238
|
-
title: featureTitle,
|
|
239
|
-
modifier,
|
|
240
|
-
tags: [...bridge.data.gherkin.tags],
|
|
241
|
-
status
|
|
242
|
-
});
|
|
243
|
-
const settled = await events.settleAsyncEvents();
|
|
244
|
-
const failedCount = settled.filter((e) => e.status === "rejected").length;
|
|
245
|
-
if (failedCount > 0) {
|
|
246
|
-
const count = `${failedCount}/${settled.length}`;
|
|
247
|
-
const message = `${count} asynchronous Test Events were rejected.`;
|
|
248
|
-
console.warn(message);
|
|
249
|
-
}
|
|
250
|
-
featureApps.clear();
|
|
251
|
-
outlineApps.clear();
|
|
252
|
-
examplesApps.clear();
|
|
253
|
-
ruleApps.clear();
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function bootstrapBackground(root, bridge, localApp, events, [config, timeout]) {
|
|
257
|
-
const background = bridge.background;
|
|
258
|
-
if (!background)
|
|
259
|
-
return;
|
|
260
|
-
const chosenTimeout = chooseTimeout(
|
|
261
|
-
timeout,
|
|
262
|
-
bridge.data.scope.timeout
|
|
263
|
-
).getTimeout(config).milliseconds;
|
|
264
|
-
const tags = bridge?.data?.gherkin?.tags ?? [];
|
|
265
|
-
if (tags.has("@skip") || tags.has("@skipped"))
|
|
266
|
-
return;
|
|
267
|
-
beforeEach(async () => {
|
|
268
|
-
const testName = expect.getState().currentTestName;
|
|
269
|
-
if (!testName)
|
|
270
|
-
throw new AutomationError("A Scenario must have a title");
|
|
271
|
-
const scenarioBridge = find(root, testName);
|
|
272
|
-
if (!scenarioBridge) {
|
|
273
|
-
throw new AutomationError(
|
|
274
|
-
`No matching scenario bridge was found matching the test name: ${testName}`
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
const title = background.data.scope.title(background.data.gherkin);
|
|
278
|
-
events.before.emitStart({
|
|
279
|
-
title,
|
|
280
|
-
tags: [...tags]
|
|
281
|
-
});
|
|
282
|
-
const steps = background.steps;
|
|
283
|
-
try {
|
|
284
|
-
for (const step of steps) {
|
|
285
|
-
const [_, app] = localApp();
|
|
286
|
-
const args = step.args?.(app) ?? [];
|
|
287
|
-
const title2 = step.data.scope.stepText(
|
|
288
|
-
step.data.gherkin.keyword,
|
|
289
|
-
step.data.gherkin.text
|
|
290
|
-
);
|
|
291
|
-
events.step.emitStart({
|
|
292
|
-
title: title2,
|
|
293
|
-
args,
|
|
294
|
-
expression: step.data.scope.expression.source
|
|
295
|
-
});
|
|
296
|
-
await step.data.scope.execute(step.data.gherkin, args, app);
|
|
297
|
-
events.step.emitEnd({
|
|
298
|
-
expression: step.data.scope.expression.source,
|
|
299
|
-
title: title2,
|
|
300
|
-
args
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
events.before.emitEnd({
|
|
304
|
-
title,
|
|
305
|
-
tags: [...tags],
|
|
306
|
-
status: "PASSED"
|
|
307
|
-
});
|
|
308
|
-
} catch (e) {
|
|
309
|
-
events.before.emitEnd({
|
|
310
|
-
title,
|
|
311
|
-
tags: [...tags],
|
|
312
|
-
status: "FAILED",
|
|
313
|
-
error: e
|
|
314
|
-
});
|
|
315
|
-
const message = `${title} failed to execute.
|
|
316
|
-
Test: ${testName}`;
|
|
317
|
-
throw new AutomationError(message, { cause: e });
|
|
318
|
-
}
|
|
319
|
-
}, chosenTimeout);
|
|
320
|
-
}
|
|
321
|
-
function bootstrapScenarios(root, bridge, localApp, staticApp, events, [config, timeout]) {
|
|
322
|
-
const { scenarios } = bridge;
|
|
323
|
-
const chosenTimeout = chooseTimeout(
|
|
324
|
-
timeout,
|
|
325
|
-
bridge.data.scope.timeout
|
|
326
|
-
).getTimeout(config);
|
|
327
|
-
scenarios.forEach((scenario) => {
|
|
328
|
-
if (isOutline(scenario)) {
|
|
329
|
-
bootstrapScenarioOutline(root, scenario, localApp, staticApp, events, [
|
|
330
|
-
config,
|
|
331
|
-
chosenTimeout
|
|
332
|
-
]);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
bootstrapScenario(scenario, localApp, events, [config, chosenTimeout]);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
function bootstrapScenario(bridge, localApp, events, [config, timeout]) {
|
|
339
|
-
const { data } = bridge;
|
|
340
|
-
const chosenTimeout = chooseTimeout(
|
|
341
|
-
timeout,
|
|
342
|
-
bridge.data.scope.timeout
|
|
343
|
-
).getTimeout(config);
|
|
344
|
-
const scenarioName = data.scope.title(data.gherkin);
|
|
345
|
-
const test = getTestOrModifier(bridge, config.current.test?.tagFilter);
|
|
346
|
-
test(
|
|
347
|
-
scenarioName,
|
|
348
|
-
async () => {
|
|
349
|
-
events.scenario.emitStart({
|
|
350
|
-
title: bridge.title,
|
|
351
|
-
tags: bridge.tags
|
|
352
|
-
});
|
|
353
|
-
const [container, app] = localApp();
|
|
354
|
-
try {
|
|
355
|
-
for (const step of bridge.steps) {
|
|
356
|
-
await tryRunStep(step, events, bridge, () => app);
|
|
357
|
-
}
|
|
358
|
-
bridge.report = { passed: true };
|
|
359
|
-
events.scenario.emitEnd({
|
|
360
|
-
title: bridge.title,
|
|
361
|
-
tags: bridge.tags,
|
|
362
|
-
status: "PASSED"
|
|
363
|
-
});
|
|
364
|
-
} catch (e) {
|
|
365
|
-
const error = e;
|
|
366
|
-
bridge.report = { passed: false, error: e };
|
|
367
|
-
events.scenario.emitEnd({
|
|
368
|
-
title: bridge.title,
|
|
369
|
-
tags: bridge.tags,
|
|
370
|
-
status: "FAILED",
|
|
371
|
-
error
|
|
372
|
-
});
|
|
373
|
-
const message = `${bridge.title} failed while executing a step`;
|
|
374
|
-
const meta = { cause: error };
|
|
375
|
-
throw new AutomationError(message, meta);
|
|
376
|
-
} finally {
|
|
377
|
-
await container.disposeAll(bridge.tags, isTagsMatch);
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
chosenTimeout.milliseconds
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
async function tryRunStep(step, events, bridge, localApp) {
|
|
384
|
-
await bootstrapStep(step, events, bridge, localApp);
|
|
385
|
-
}
|
|
386
|
-
async function bootstrapStep(step, events, bridge, localApp) {
|
|
387
|
-
const title = step.data.scope.stepText(
|
|
388
|
-
step.data.gherkin.keyword,
|
|
389
|
-
step.data.gherkin.text
|
|
390
|
-
);
|
|
391
|
-
let args = [];
|
|
392
|
-
try {
|
|
393
|
-
const app = localApp();
|
|
394
|
-
args = step.args?.(app) ?? [];
|
|
395
|
-
events.step.emitStart({
|
|
396
|
-
title,
|
|
397
|
-
args,
|
|
398
|
-
expression: step.expressionText
|
|
399
|
-
});
|
|
400
|
-
await step.data.scope.execute(step.data.gherkin, args, app);
|
|
401
|
-
events.step.emitEnd({
|
|
402
|
-
expression: step.expressionText,
|
|
403
|
-
title,
|
|
404
|
-
args,
|
|
405
|
-
status: "PASSED"
|
|
406
|
-
});
|
|
407
|
-
} catch (e) {
|
|
408
|
-
const error = e;
|
|
409
|
-
events.step.emitEnd({
|
|
410
|
-
expression: step.expressionText,
|
|
411
|
-
title,
|
|
412
|
-
args,
|
|
413
|
-
status: "FAILED",
|
|
414
|
-
error: e
|
|
415
|
-
});
|
|
416
|
-
const message = `${title} experienced an error`;
|
|
417
|
-
const meta = { cause: error };
|
|
418
|
-
const newError = new AutomationError(message, meta);
|
|
419
|
-
console.error(formatErrorCauses(newError));
|
|
420
|
-
throw newError;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function isOutline(data) {
|
|
424
|
-
return data instanceof ScenarioOutlineBridge;
|
|
425
|
-
}
|
|
426
|
-
function bootstrapScenarioOutline(root, bridge, localApp, staticApp, events, [config, timeout]) {
|
|
427
|
-
const {
|
|
428
|
-
data: { scope, gherkin },
|
|
429
|
-
examples
|
|
430
|
-
} = bridge;
|
|
431
|
-
const title = scope.title(gherkin);
|
|
432
|
-
const retry = [...gherkin.tags].find((tag) => tag.startsWith("@retries="));
|
|
433
|
-
const { beforeScenarioOutlineHooks, afterScenarioOutlineHooks } = scope.hooks;
|
|
434
|
-
const [group, modifier] = getGroupOrModifier(bridge);
|
|
435
|
-
const chosenTimeout = chooseTimeout(
|
|
436
|
-
timeout,
|
|
437
|
-
bridge.data.scope.timeout
|
|
438
|
-
).getTimeout(config).milliseconds;
|
|
439
|
-
const original = localApp;
|
|
440
|
-
localApp = () => {
|
|
441
|
-
const testName = expect.getState().currentTestName;
|
|
442
|
-
if (!outlineApps.has(testName)) {
|
|
443
|
-
outlineApps.set(testName, []);
|
|
444
|
-
}
|
|
445
|
-
const apps = outlineApps.get(testName);
|
|
446
|
-
const [container, app] = original();
|
|
447
|
-
apps.push(app);
|
|
448
|
-
return [container, app];
|
|
449
|
-
};
|
|
450
|
-
group(title, () => {
|
|
451
|
-
beforeScenarioOutlineHooks.forEach((hook) => {
|
|
452
|
-
const hookTimeout = chooseTimeout(
|
|
453
|
-
timeout,
|
|
454
|
-
hook.options.timeout
|
|
455
|
-
).getTimeout(config).milliseconds;
|
|
456
|
-
beforeAll(async () => {
|
|
457
|
-
if (!hook.canExecute(...gherkin.tags)) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
events.beforeScenarioOutline.emitStart({
|
|
461
|
-
title,
|
|
462
|
-
modifier,
|
|
463
|
-
tags: [...gherkin.tags]
|
|
464
|
-
});
|
|
465
|
-
const tags = gherkin.tags ?? [];
|
|
466
|
-
events.beforeScenarioOutline.emitStart({
|
|
467
|
-
title,
|
|
468
|
-
modifier,
|
|
469
|
-
tags: [...gherkin.tags]
|
|
470
|
-
});
|
|
471
|
-
const report = await hook.execute(staticApp, ...tags);
|
|
472
|
-
if (report.error) {
|
|
473
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
474
|
-
events.beforeScenarioOutline.emitEnd({
|
|
475
|
-
title,
|
|
476
|
-
modifier,
|
|
477
|
-
error: report.error,
|
|
478
|
-
tags: [...gherkin.tags],
|
|
479
|
-
status: "FAILED"
|
|
480
|
-
});
|
|
481
|
-
throw new AutomationError(message, { cause: report.error });
|
|
482
|
-
}
|
|
483
|
-
events.beforeScenarioOutline.emitEnd({
|
|
484
|
-
title,
|
|
485
|
-
modifier,
|
|
486
|
-
tags: [...gherkin.tags],
|
|
487
|
-
status: "PASSED"
|
|
488
|
-
});
|
|
489
|
-
}, hookTimeout);
|
|
490
|
-
});
|
|
491
|
-
beforeAll(() => {
|
|
492
|
-
if (retry) {
|
|
493
|
-
const count = parseInt(retry.split("=")[1]);
|
|
494
|
-
jest.retryTimes(count);
|
|
495
|
-
}
|
|
496
|
-
events.scenarioOutline.emitStart({
|
|
497
|
-
title,
|
|
498
|
-
modifier,
|
|
499
|
-
tags: [...gherkin.tags]
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
bootstrapSetupHooks(bridge, staticApp, events, [config, timeout]);
|
|
503
|
-
bootstrapBeforeHooks(root, bridge, localApp, events, [config, timeout]);
|
|
504
|
-
examples.forEach((example) => {
|
|
505
|
-
bootstrapExamples(root, example, localApp, staticApp, events, [
|
|
506
|
-
config,
|
|
507
|
-
timeout
|
|
508
|
-
]);
|
|
509
|
-
});
|
|
510
|
-
bootstrapAfterHooks(root, bridge, localApp, events, [config, timeout]);
|
|
511
|
-
bootstrapTeardownHooks(bridge, staticApp, events, [config, timeout]);
|
|
512
|
-
afterScenarioOutlineHooks.forEach((hook) => {
|
|
513
|
-
const hookTimeout = chooseTimeout(
|
|
514
|
-
timeout,
|
|
515
|
-
hook.options.timeout
|
|
516
|
-
).getTimeout(config).milliseconds;
|
|
517
|
-
afterAll(async () => {
|
|
518
|
-
if (!hook.canExecute(...gherkin.tags)) {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
const testName = expect.getState().currentTestName;
|
|
522
|
-
const tags = gherkin.tags ?? [];
|
|
523
|
-
const apps = outlineApps.get(testName);
|
|
524
|
-
events.afterScenarioOutline.emitStart({
|
|
525
|
-
title,
|
|
526
|
-
modifier,
|
|
527
|
-
tags: [...gherkin.tags]
|
|
528
|
-
});
|
|
529
|
-
const report = await hook.execute(staticApp, apps, ...tags);
|
|
530
|
-
if (report.error) {
|
|
531
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
532
|
-
events.scenarioOutline.emitEnd({
|
|
533
|
-
title,
|
|
534
|
-
modifier,
|
|
535
|
-
error: report.error,
|
|
536
|
-
tags: [...gherkin.tags],
|
|
537
|
-
status: "FAILED"
|
|
538
|
-
});
|
|
539
|
-
throw new AutomationError(message, { cause: report.error });
|
|
540
|
-
}
|
|
541
|
-
events.afterScenarioOutline.emitEnd({
|
|
542
|
-
title,
|
|
543
|
-
modifier,
|
|
544
|
-
tags: [...gherkin.tags],
|
|
545
|
-
status: "PASSED"
|
|
546
|
-
});
|
|
547
|
-
}, hookTimeout);
|
|
548
|
-
});
|
|
549
|
-
afterAll(() => {
|
|
550
|
-
const failures = Query.find.failed(bridge);
|
|
551
|
-
const status = getStatus(modifier, failures);
|
|
552
|
-
events.scenarioOutline.emitEnd({
|
|
553
|
-
title,
|
|
554
|
-
modifier,
|
|
555
|
-
tags: [...gherkin.tags],
|
|
556
|
-
status
|
|
557
|
-
});
|
|
558
|
-
outlineApps.clear();
|
|
559
|
-
examplesApps.clear();
|
|
560
|
-
}, chosenTimeout);
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
function bootstrapExamples(root, example, localApp, staticApp, events, timeout) {
|
|
564
|
-
const { gherkin } = example.data;
|
|
565
|
-
const title = `${gherkin.keyword}: ${gherkin.name}`;
|
|
566
|
-
const retry = [...example.data.gherkin.tags].find(
|
|
567
|
-
(tag) => tag.startsWith("@retries=")
|
|
568
|
-
);
|
|
569
|
-
const original = localApp;
|
|
570
|
-
localApp = () => {
|
|
571
|
-
const testName = expect.getState().currentTestName ?? "unnamed test";
|
|
572
|
-
if (!examplesApps.has(testName)) {
|
|
573
|
-
examplesApps.set(testName, []);
|
|
574
|
-
}
|
|
575
|
-
const apps = examplesApps.get(testName);
|
|
576
|
-
const [container, app] = original();
|
|
577
|
-
apps.push(app);
|
|
578
|
-
return [container, app];
|
|
579
|
-
};
|
|
580
|
-
const [group] = getGroupOrModifier(example);
|
|
581
|
-
group(title, () => {
|
|
582
|
-
beforeAll(() => {
|
|
583
|
-
if (retry) {
|
|
584
|
-
const count = parseInt(retry.split("=")[1]);
|
|
585
|
-
jest.retryTimes(count);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
example.data.scope.hooks.beforeExamplesHooks.forEach((hook) => {
|
|
589
|
-
const hookTimeout = chooseTimeout(
|
|
590
|
-
timeout[1],
|
|
591
|
-
hook.options.timeout
|
|
592
|
-
).getTimeout(timeout[0]).milliseconds;
|
|
593
|
-
beforeAll(async () => {
|
|
594
|
-
if (!hook.canExecute(...example.data.gherkin.tags)) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
const tags = example?.data?.gherkin?.tags ?? [];
|
|
598
|
-
events.beforeExamples.emitStart({
|
|
599
|
-
title,
|
|
600
|
-
tags: [...tags]
|
|
601
|
-
});
|
|
602
|
-
const report = await hook.execute(staticApp, ...tags);
|
|
603
|
-
if (report.error) {
|
|
604
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
605
|
-
events.beforeExamples.emitEnd({
|
|
606
|
-
title,
|
|
607
|
-
error: report.error,
|
|
608
|
-
tags: [...tags],
|
|
609
|
-
status: "FAILED"
|
|
610
|
-
});
|
|
611
|
-
throw new AutomationError(message, { cause: report.error });
|
|
612
|
-
}
|
|
613
|
-
events.beforeExamples.emitEnd({
|
|
614
|
-
title,
|
|
615
|
-
tags: [...tags],
|
|
616
|
-
status: "PASSED"
|
|
617
|
-
});
|
|
618
|
-
}, hookTimeout);
|
|
619
|
-
});
|
|
620
|
-
bootstrapScenarios(root, example, localApp, staticApp, events, timeout);
|
|
621
|
-
example.data.scope.hooks.afterExamplesHooks.forEach((hook) => {
|
|
622
|
-
const hookTimeout = chooseTimeout(
|
|
623
|
-
timeout[1],
|
|
624
|
-
hook.options.timeout
|
|
625
|
-
).getTimeout(timeout[0]).milliseconds;
|
|
626
|
-
afterAll(async () => {
|
|
627
|
-
const testName = expect.getState().currentTestName;
|
|
628
|
-
if (!hook.canExecute(...example.data.gherkin.tags)) {
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
const tags = example?.data?.gherkin?.tags ?? [];
|
|
632
|
-
const apps = examplesApps.get(testName);
|
|
633
|
-
const report = await hook.execute(staticApp, apps, ...tags);
|
|
634
|
-
if (report.error) {
|
|
635
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
636
|
-
throw new AutomationError(message, { cause: report.error });
|
|
637
|
-
}
|
|
638
|
-
}, hookTimeout);
|
|
639
|
-
});
|
|
640
|
-
afterAll(() => {
|
|
641
|
-
const testName = expect.getState().currentTestName;
|
|
642
|
-
examplesApps.delete(testName);
|
|
643
|
-
});
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
function bootstrapRules(bridge, localApp, staticApp, events, [config, timeout]) {
|
|
647
|
-
const chosenTimeout = chooseTimeout(
|
|
648
|
-
timeout,
|
|
649
|
-
bridge.data.scope.timeout
|
|
650
|
-
).getTimeout(config);
|
|
651
|
-
bridge.rules.forEach((rule) => {
|
|
652
|
-
const tags = [...rule.data.gherkin.tags];
|
|
653
|
-
const retry = tags.find((tag) => tag.startsWith("@retries="));
|
|
654
|
-
const ruleTimeout = chooseTimeout(
|
|
655
|
-
chosenTimeout,
|
|
656
|
-
rule.data.scope.timeout
|
|
657
|
-
).getTimeout(config);
|
|
658
|
-
const transferTimeout = [config, ruleTimeout];
|
|
659
|
-
const { data } = rule;
|
|
660
|
-
const ruleName = data.scope.title(data.gherkin);
|
|
661
|
-
const [group, modifier] = getGroupOrModifier(bridge);
|
|
662
|
-
group(ruleName, () => {
|
|
663
|
-
beforeAll(() => {
|
|
664
|
-
events.rule.emitStart({
|
|
665
|
-
title: ruleName,
|
|
666
|
-
modifier,
|
|
667
|
-
tags: [...data.gherkin.tags]
|
|
668
|
-
});
|
|
669
|
-
if (retry) {
|
|
670
|
-
const count = parseInt(retry.split("=")[1]);
|
|
671
|
-
jest.retryTimes(count);
|
|
672
|
-
}
|
|
673
|
-
const original = localApp;
|
|
674
|
-
localApp = () => {
|
|
675
|
-
const testName = expect.getState().currentTestName;
|
|
676
|
-
if (!ruleApps.has(testName)) {
|
|
677
|
-
ruleApps.set(testName, []);
|
|
678
|
-
}
|
|
679
|
-
const apps = ruleApps.get(testName);
|
|
680
|
-
const [container, app] = original();
|
|
681
|
-
apps.push(app);
|
|
682
|
-
return [container, app];
|
|
683
|
-
};
|
|
684
|
-
});
|
|
685
|
-
bridge.data.scope.hooks.beforeRuleHooks.forEach((hook) => {
|
|
686
|
-
const hookTimeout = chooseTimeout(
|
|
687
|
-
ruleTimeout,
|
|
688
|
-
hook.options.timeout
|
|
689
|
-
).getTimeout(config).milliseconds;
|
|
690
|
-
beforeAll(async () => {
|
|
691
|
-
if (!hook.canExecute(...data.gherkin.tags)) {
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
const tags2 = data.gherkin.tags ?? [];
|
|
695
|
-
events.beforeRule.emitStart({
|
|
696
|
-
title: `${hook.name}: ${hook.description}`,
|
|
697
|
-
tags: [...tags2]
|
|
698
|
-
});
|
|
699
|
-
const report = await hook.execute(staticApp, ...tags2);
|
|
700
|
-
if (report.error) {
|
|
701
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
702
|
-
events.beforeRule.emitEnd({
|
|
703
|
-
title: `${hook.name}: ${hook.description}`,
|
|
704
|
-
tags: [...tags2],
|
|
705
|
-
status: "FAILED",
|
|
706
|
-
error: report.error
|
|
707
|
-
});
|
|
708
|
-
throw new AutomationError(message, { cause: report.error });
|
|
709
|
-
}
|
|
710
|
-
events.beforeRule.emitEnd({
|
|
711
|
-
title: `${hook.name}: ${hook.description}`,
|
|
712
|
-
tags: [...tags2],
|
|
713
|
-
status: "PASSED"
|
|
714
|
-
});
|
|
715
|
-
}, hookTimeout);
|
|
716
|
-
});
|
|
717
|
-
bridge.data.scope.hooks.afterRuleHooks.forEach((hook) => {
|
|
718
|
-
const hookTimeout = chooseTimeout(
|
|
719
|
-
ruleTimeout,
|
|
720
|
-
hook.options.timeout
|
|
721
|
-
).getTimeout(config).milliseconds;
|
|
722
|
-
afterAll(async () => {
|
|
723
|
-
const testName = expect.getState().currentTestName;
|
|
724
|
-
if (!hook.canExecute(...data.gherkin.tags)) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
const tags2 = data.gherkin.tags ?? [];
|
|
728
|
-
const apps = ruleApps.get(testName);
|
|
729
|
-
events.afterRule.emitStart({
|
|
730
|
-
title: `${hook.name}: ${hook.description}`,
|
|
731
|
-
tags: [...tags2]
|
|
732
|
-
});
|
|
733
|
-
const report = await hook.execute(staticApp, apps, ...tags2);
|
|
734
|
-
if (report.error) {
|
|
735
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
736
|
-
events.afterRule.emitEnd({
|
|
737
|
-
title: `${hook.name}: ${hook.description}`,
|
|
738
|
-
tags: [...tags2],
|
|
739
|
-
status: "FAILED",
|
|
740
|
-
error: report.error
|
|
741
|
-
});
|
|
742
|
-
throw new AutomationError(message, { cause: report.error });
|
|
743
|
-
}
|
|
744
|
-
events.afterRule.emitEnd({
|
|
745
|
-
title: `${hook.name}: ${hook.description}`,
|
|
746
|
-
tags: [...tags2],
|
|
747
|
-
status: "PASSED"
|
|
748
|
-
});
|
|
749
|
-
}, hookTimeout);
|
|
750
|
-
});
|
|
751
|
-
bootstrapSetupHooks(rule, staticApp, events, transferTimeout);
|
|
752
|
-
bootstrapBeforeHooks(bridge, rule, localApp, events, transferTimeout);
|
|
753
|
-
bootstrapBackground(bridge, rule, localApp, events, transferTimeout);
|
|
754
|
-
bootstrapScenarios(
|
|
755
|
-
bridge,
|
|
756
|
-
rule,
|
|
757
|
-
localApp,
|
|
758
|
-
staticApp,
|
|
759
|
-
events,
|
|
760
|
-
transferTimeout
|
|
761
|
-
);
|
|
762
|
-
bootstrapAfterHooks(bridge, rule, localApp, events, transferTimeout);
|
|
763
|
-
bootstrapTeardownHooks(rule, staticApp, events, transferTimeout);
|
|
764
|
-
afterAll(() => {
|
|
765
|
-
const failures = Query.find.failed(rule);
|
|
766
|
-
const status = getStatus(modifier, failures);
|
|
767
|
-
events.rule.emitEnd({
|
|
768
|
-
title: ruleName,
|
|
769
|
-
modifier,
|
|
770
|
-
tags: [...data.gherkin.tags],
|
|
771
|
-
status
|
|
772
|
-
});
|
|
773
|
-
const testName = expect.getState().currentTestName;
|
|
774
|
-
ruleApps.delete(testName);
|
|
775
|
-
}, ruleTimeout.milliseconds);
|
|
776
|
-
});
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
function getStatus(modifier, failures) {
|
|
780
|
-
if (modifier === "skip") {
|
|
781
|
-
return "SKIPPED";
|
|
782
|
-
}
|
|
783
|
-
if (failures.length === 0) {
|
|
784
|
-
return "PASSED";
|
|
785
|
-
}
|
|
786
|
-
return "FAILED";
|
|
787
|
-
}
|
|
788
|
-
function getGroupOrModifier(bridge) {
|
|
789
|
-
const { data } = bridge;
|
|
790
|
-
if (data.gherkin.tags?.has("@skip") || data.gherkin.tags?.has("@skipped")) {
|
|
791
|
-
return [describe.skip, "skip"];
|
|
792
|
-
}
|
|
793
|
-
if (data.gherkin.tags?.has("@only")) {
|
|
794
|
-
return [describe.only, "only"];
|
|
795
|
-
}
|
|
796
|
-
return [describe, void 0];
|
|
797
|
-
}
|
|
798
|
-
function getTestOrModifier({ data }, tagFilter) {
|
|
799
|
-
if (data.gherkin.tags?.has("@skip") || data.gherkin.tags?.has("@skipped")) {
|
|
800
|
-
return it.skip;
|
|
801
|
-
}
|
|
802
|
-
if (data.gherkin.tags?.has("@only")) {
|
|
803
|
-
return it.only;
|
|
804
|
-
}
|
|
805
|
-
if (tagFilter) {
|
|
806
|
-
const parse = __require("@cucumber/tag-expressions").default;
|
|
807
|
-
const expression = parse(tagFilter).evaluate([...data.gherkin.tags]);
|
|
808
|
-
if (!expression) {
|
|
809
|
-
return it.skip;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
return it;
|
|
813
|
-
}
|
|
814
|
-
function bootstrapBeforeHooks(root, bridge, localApp, events, [config, timeout]) {
|
|
815
|
-
const chosenTimeout = chooseTimeout(
|
|
816
|
-
timeout,
|
|
817
|
-
bridge.data.scope.timeout
|
|
818
|
-
).getTimeout(config);
|
|
819
|
-
bridge.data.scope.hooks.before.forEach((hook) => {
|
|
820
|
-
const hookTimeout = chooseTimeout(
|
|
821
|
-
chosenTimeout,
|
|
822
|
-
hook.options.timeout
|
|
823
|
-
).getTimeout(config).milliseconds;
|
|
824
|
-
beforeEach(async () => {
|
|
825
|
-
const testName = expect.getState().currentTestName;
|
|
826
|
-
if (!testName)
|
|
827
|
-
throw new AutomationError("A Scenario must have a title");
|
|
828
|
-
const scenarioBridge = find(root, testName);
|
|
829
|
-
if (!scenarioBridge) {
|
|
830
|
-
throw new AutomationError(
|
|
831
|
-
`No matching scenario was found matching the test name: ${testName}`
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
if (!hook.canExecute(...scenarioBridge.data.gherkin.tags)) {
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
const tags = scenarioBridge?.data?.gherkin?.tags ?? [];
|
|
838
|
-
events.before.emitStart({
|
|
839
|
-
title: `${hook.name}: ${hook.description}`,
|
|
840
|
-
tags: [...tags]
|
|
841
|
-
});
|
|
842
|
-
const report = await hook.execute(localApp()[1], ...tags);
|
|
843
|
-
events.before.emitEnd({
|
|
844
|
-
title: `${hook.name}: ${hook.description}`,
|
|
845
|
-
tags: [...tags],
|
|
846
|
-
status: report.status,
|
|
847
|
-
error: report.error
|
|
848
|
-
});
|
|
849
|
-
if (report.error) {
|
|
850
|
-
const message = `${hook.name}: ${hook.description} experienced a failure.`;
|
|
851
|
-
throw new AutomationError(message, { cause: report.error });
|
|
852
|
-
}
|
|
853
|
-
}, hookTimeout);
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
function bootstrapSetupHooks(bridge, staticApp, events, [config, timeout]) {
|
|
857
|
-
const { scope, gherkin } = bridge.data;
|
|
858
|
-
const chosenTimeout = chooseTimeout(
|
|
859
|
-
timeout,
|
|
860
|
-
bridge.data.scope.timeout
|
|
861
|
-
).getTimeout(config).milliseconds;
|
|
862
|
-
const setups = scope.hooks.setup;
|
|
863
|
-
setups.forEach((hook) => {
|
|
864
|
-
const hookTimeout = chooseTimeout(
|
|
865
|
-
Timeout2.from(chosenTimeout),
|
|
866
|
-
hook.options.timeout
|
|
867
|
-
).getTimeout(config).milliseconds;
|
|
868
|
-
const tags = gherkin.tags ?? [];
|
|
869
|
-
beforeAll(async () => {
|
|
870
|
-
if (!hook.canExecute(...tags)) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
events.setup.emitStart({
|
|
874
|
-
title: `${hook.name}: ${hook.description}`
|
|
875
|
-
});
|
|
876
|
-
const report = await hook.execute(staticApp, ...tags);
|
|
877
|
-
events.setup.emitEnd({
|
|
878
|
-
title: `${hook.name}: ${hook.description}`,
|
|
879
|
-
status: report.status,
|
|
880
|
-
error: report.error
|
|
881
|
-
});
|
|
882
|
-
if (report.error) {
|
|
883
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
884
|
-
throw new AutomationError(message, { cause: report.error });
|
|
885
|
-
}
|
|
886
|
-
}, hookTimeout);
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
function bootstrapAfterHooks(root, bridge, localApp, events, [config, timeout]) {
|
|
890
|
-
const { scope } = bridge.data;
|
|
891
|
-
const chosenTimeout = chooseTimeout(timeout, scope.timeout).getTimeout(
|
|
892
|
-
config
|
|
893
|
-
).milliseconds;
|
|
894
|
-
scope.hooks.after.forEach((hook) => {
|
|
895
|
-
const hookTimeout = chooseTimeout(
|
|
896
|
-
Timeout2.from(chosenTimeout),
|
|
897
|
-
hook.options.timeout
|
|
898
|
-
).getTimeout(config).milliseconds;
|
|
899
|
-
afterEach(async () => {
|
|
900
|
-
const testName = expect.getState().currentTestName;
|
|
901
|
-
if (!testName)
|
|
902
|
-
throw new AutomationError("A Scenario must have a title");
|
|
903
|
-
const scenarioBridge = find(root, testName);
|
|
904
|
-
if (!scenarioBridge) {
|
|
905
|
-
throw new AutomationError(
|
|
906
|
-
`No scenario was found matching the test path: ${testName}`
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
if (!hook.canExecute(...scenarioBridge.data.gherkin.tags)) {
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
const tags = scenarioBridge?.data?.gherkin?.tags ?? [];
|
|
913
|
-
events.after.emitStart({
|
|
914
|
-
title: `${hook.name}: ${hook.description}`,
|
|
915
|
-
tags: [...tags]
|
|
916
|
-
});
|
|
917
|
-
const report = await hook.execute(localApp()[1], ...tags);
|
|
918
|
-
events.after.emitEnd({
|
|
919
|
-
title: `${hook.name}: ${hook.description}`,
|
|
920
|
-
tags: [...tags],
|
|
921
|
-
status: report.status,
|
|
922
|
-
error: report.error
|
|
923
|
-
});
|
|
924
|
-
if (report.error) {
|
|
925
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
926
|
-
throw new AutomationError(message, { cause: report.error });
|
|
927
|
-
}
|
|
928
|
-
}, hookTimeout);
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
function bootstrapTeardownHooks(bridge, staticApp, event, [config, timeout]) {
|
|
932
|
-
const tags = [...bridge.data.gherkin.tags];
|
|
933
|
-
const { scope } = bridge.data;
|
|
934
|
-
const chosenTimeout = chooseTimeout(timeout, scope.timeout).getTimeout(
|
|
935
|
-
config
|
|
936
|
-
);
|
|
937
|
-
scope.hooks.teardown.forEach((hook) => {
|
|
938
|
-
const hookTimeout = chooseTimeout(
|
|
939
|
-
chosenTimeout,
|
|
940
|
-
hook.options.timeout
|
|
941
|
-
).getTimeout(config).milliseconds;
|
|
942
|
-
afterAll(async () => {
|
|
943
|
-
if (!hook.canExecute(...tags)) {
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
event.teardown.emitStart({
|
|
947
|
-
title: `${hook.name}: ${hook.description}`,
|
|
948
|
-
tags: [...tags]
|
|
949
|
-
});
|
|
950
|
-
const report = await hook.execute(staticApp, tags);
|
|
951
|
-
event.teardown.emitEnd({
|
|
952
|
-
title: `${hook.name}: ${hook.description}`,
|
|
953
|
-
tags: [...tags],
|
|
954
|
-
status: report.status,
|
|
955
|
-
error: report.error
|
|
956
|
-
});
|
|
957
|
-
if (report.error) {
|
|
958
|
-
const message = `${hook.name}: ${hook.description} failed to execute.`;
|
|
959
|
-
throw new AutomationError(message, { cause: report.error });
|
|
960
|
-
}
|
|
961
|
-
}, hookTimeout);
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
// src/index.ts
|
|
966
|
-
var src_default = execute;
|
|
967
|
-
export {
|
|
968
|
-
src_default as default,
|
|
969
|
-
execute,
|
|
970
|
-
getTimeout
|
|
971
|
-
};
|
|
972
|
-
//# sourceMappingURL=index.js.map
|