@wdio/cucumber-framework 7.20.3 → 7.20.8-alpha.219
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/build/constants.d.ts +2 -2
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +5 -9
- package/build/cucumberEventListener.d.ts +2 -2
- package/build/cucumberEventListener.d.ts.map +1 -1
- package/build/cucumberEventListener.js +34 -42
- package/build/index.d.ts +4 -11
- package/build/index.d.ts.map +1 -1
- package/build/index.js +65 -114
- package/build/reporter.d.ts +4 -5
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +36 -46
- package/build/types.js +1 -2
- package/build/utils.d.ts +2 -2
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +26 -49
- package/package.json +12 -11
package/build/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CucumberOptions } from './types';
|
|
2
|
-
import { Pickle, PickleStep } from '@cucumber/messages';
|
|
1
|
+
import type { CucumberOptions } from './types';
|
|
2
|
+
import type { Pickle, PickleStep } from '@cucumber/messages';
|
|
3
3
|
export declare const DEFAULT_TIMEOUT = 60000;
|
|
4
4
|
export declare const DEFAULT_OPTS: CucumberOptions;
|
|
5
5
|
export declare const NOOP: () => void;
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE5D,eAAO,MAAM,eAAe,QAAQ,CAAA;AAEpC,eAAO,MAAM,YAAY,EAAE,eAkB1B,CAAA;AAGD,eAAO,MAAM,IAAI,YAAiB,CAAA;AAElC,eAAO,MAAM,8BAA8B,mKAKjC,CAAA;AAEV;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,MAAM;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
package/build/constants.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CUCUMBER_HOOK_DEFINITION_TYPES = exports.NOOP = exports.DEFAULT_OPTS = exports.DEFAULT_TIMEOUT = void 0;
|
|
4
|
-
exports.DEFAULT_TIMEOUT = 60000;
|
|
5
|
-
exports.DEFAULT_OPTS = {
|
|
1
|
+
export const DEFAULT_TIMEOUT = 60000;
|
|
2
|
+
export const DEFAULT_OPTS = {
|
|
6
3
|
backtrace: false,
|
|
7
4
|
requireModule: [],
|
|
8
5
|
failAmbiguousDefinitions: false,
|
|
@@ -16,15 +13,14 @@ exports.DEFAULT_OPTS = {
|
|
|
16
13
|
strict: false,
|
|
17
14
|
tagExpression: '',
|
|
18
15
|
tagsInTitle: false,
|
|
19
|
-
timeout:
|
|
16
|
+
timeout: DEFAULT_TIMEOUT,
|
|
20
17
|
retry: 0,
|
|
21
18
|
scenarioLevelReporter: false,
|
|
22
19
|
featureDefaultLanguage: 'en'
|
|
23
20
|
};
|
|
24
21
|
/* istanbul ignore next */
|
|
25
|
-
const NOOP = function () { };
|
|
26
|
-
|
|
27
|
-
exports.CUCUMBER_HOOK_DEFINITION_TYPES = [
|
|
22
|
+
export const NOOP = function () { };
|
|
23
|
+
export const CUCUMBER_HOOK_DEFINITION_TYPES = [
|
|
28
24
|
'beforeTestRunHookDefinitionConfigs',
|
|
29
25
|
'beforeTestCaseHookDefinitionConfigs',
|
|
30
26
|
'afterTestCaseHookDefinitionConfigs',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { PickleFilter } from '@cucumber/cucumber';
|
|
4
4
|
import { Pickle, TestCase, TestStepResult, TestCaseStarted, GherkinDocument, TestStepStarted, TestStepFinished } from '@cucumber/messages';
|
|
5
5
|
import type { Capabilities } from '@wdio/types';
|
|
6
|
-
import { HookParams } from './types';
|
|
6
|
+
import type { HookParams } from './types';
|
|
7
7
|
export default class CucumberEventListener extends EventEmitter {
|
|
8
8
|
private _pickleFilter;
|
|
9
9
|
private _gherkinDocEvents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cucumberEventListener.d.ts","sourceRoot":"","sources":["../src/cucumberEventListener.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cucumberEventListener.d.ts","sourceRoot":"","sources":["../src/cucumberEventListener.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAU,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EACH,MAAM,EAAE,QAAQ,EAAY,cAAc,EAAE,eAAe,EAAE,eAAe,EAC5E,eAAe,EAAE,gBAAgB,EACpC,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIzC,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,YAAY;IAWd,OAAO,CAAC,aAAa;IAVlE,OAAO,CAAC,iBAAiB,CAAwB;IACjD,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,gBAAgB,CAAC,CAAiB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,WAAW,CAAoC;IACvD,OAAO,CAAC,gBAAgB,CAAe;gBAE1B,gBAAgB,EAAE,YAAY,EAAU,aAAa,EAAE,YAAY;IAuChF,gBAAgB;IAIhB,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAoDhC,iBAAiB,CAAE,eAAe,EAAE,eAAe;IAgCnD,gBAAgB,CAAE,WAAW,EAAE,MAAM;IAgBrC,gBAAgB;IA4EhB,kBAAkB,CAAE,QAAQ,EAAE,QAAQ;IAetC,iBAAiB,CAAE,QAAQ,EAAE,eAAe;IAkD5C,iBAAiB,CAAE,oBAAoB,EAAE,eAAe;IAoCxD,kBAAkB,CAAE,qBAAqB,EAAE,gBAAgB;IA6B3D,kBAAkB,CACd,OAAO,EAAE,cAAc,EAAE;IA4B7B,iBAAiB;IAkBjB,aAAa;IAIb;;;OAGG;IACH,YAAY,CAAE,IAAI,EAAE,YAAY,CAAC,gBAAgB;CAgBpD"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const cucumber_1 = require("@cucumber/cucumber");
|
|
8
|
-
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
|
-
const log = (0, logger_1.default)('CucumberEventListener');
|
|
11
|
-
class CucumberEventListener extends events_1.EventEmitter {
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { Status } from '@cucumber/cucumber';
|
|
3
|
+
import logger from '@wdio/logger';
|
|
4
|
+
import { addKeywordToStep, filterPickles, getRule } from './utils.js';
|
|
5
|
+
const log = logger('CucumberEventListener');
|
|
6
|
+
export default class CucumberEventListener extends EventEmitter {
|
|
12
7
|
constructor(eventBroadcaster, _pickleFilter) {
|
|
13
8
|
super();
|
|
14
9
|
this._pickleFilter = _pickleFilter;
|
|
@@ -258,14 +253,14 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
258
253
|
onTestCaseStarted(testcase) {
|
|
259
254
|
this._currentTestCase = testcase;
|
|
260
255
|
const tc = this._testCases.find(tc => tc.id === testcase.testCaseId);
|
|
261
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc
|
|
256
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc?.pickleId));
|
|
262
257
|
/* istanbul ignore if */
|
|
263
258
|
if (!scenario) {
|
|
264
259
|
return;
|
|
265
260
|
}
|
|
266
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri ===
|
|
267
|
-
const uri = doc
|
|
268
|
-
const feature = doc
|
|
261
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario?.uri);
|
|
262
|
+
const uri = doc?.uri;
|
|
263
|
+
const feature = doc?.feature;
|
|
269
264
|
if (this._currentDoc.uri && this._currentDoc.feature && this.usesSpecGrouping() && doc != this._currentDoc && this.featureIsStarted(this._currentDoc.uri)) {
|
|
270
265
|
this.emit('after-feature', this._currentDoc.uri, this._currentDoc.feature);
|
|
271
266
|
}
|
|
@@ -280,12 +275,12 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
280
275
|
* This will aad them
|
|
281
276
|
*/
|
|
282
277
|
if (scenario.steps && feature) {
|
|
283
|
-
scenario.steps =
|
|
278
|
+
scenario.steps = addKeywordToStep(scenario.steps, feature);
|
|
284
279
|
}
|
|
285
280
|
this._currentPickle = { uri, feature, scenario };
|
|
286
281
|
let reporterScenario = scenario;
|
|
287
|
-
reporterScenario.rule =
|
|
288
|
-
this.emit('before-scenario', scenario.uri, doc
|
|
282
|
+
reporterScenario.rule = getRule(doc?.feature, this._pickleMap.get(scenario.id));
|
|
283
|
+
this.emit('before-scenario', scenario.uri, doc?.feature, reporterScenario);
|
|
289
284
|
}
|
|
290
285
|
// {
|
|
291
286
|
// "testStepStarted": {
|
|
@@ -298,14 +293,13 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
298
293
|
// }
|
|
299
294
|
// }
|
|
300
295
|
onTestStepStarted(testStepStartedEvent) {
|
|
301
|
-
var _a, _b;
|
|
302
296
|
const testcase = this._testCases.find((testcase) => this._currentTestCase && testcase.id === this._currentTestCase.testCaseId);
|
|
303
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase
|
|
304
|
-
const teststep =
|
|
305
|
-
const step =
|
|
306
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri ===
|
|
307
|
-
const uri = doc
|
|
308
|
-
const feature = doc
|
|
297
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase?.pickleId));
|
|
298
|
+
const teststep = testcase?.testSteps?.find((step) => step.id === testStepStartedEvent.testStepId);
|
|
299
|
+
const step = scenario?.steps?.find((s) => s.id === teststep?.pickleStepId) || teststep;
|
|
300
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario?.uri);
|
|
301
|
+
const uri = doc?.uri;
|
|
302
|
+
const feature = doc?.feature;
|
|
309
303
|
/* istanbul ignore if */
|
|
310
304
|
if (!step) {
|
|
311
305
|
return;
|
|
@@ -331,15 +325,14 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
331
325
|
// }
|
|
332
326
|
// }
|
|
333
327
|
onTestStepFinished(testStepFinishedEvent) {
|
|
334
|
-
|
|
335
|
-
const
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
const step = ((_b = scenario === null || scenario === void 0 ? void 0 : scenario.steps) === null || _b === void 0 ? void 0 : _b.find((s) => s.id === (teststep === null || teststep === void 0 ? void 0 : teststep.pickleStepId))) || teststep;
|
|
328
|
+
const testcase = this._testCases.find((testcase) => testcase.id === this._currentTestCase?.testCaseId);
|
|
329
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase?.pickleId));
|
|
330
|
+
const teststep = testcase?.testSteps?.find((step) => step.id === testStepFinishedEvent.testStepId);
|
|
331
|
+
const step = scenario?.steps?.find((s) => s.id === teststep?.pickleStepId) || teststep;
|
|
339
332
|
const result = testStepFinishedEvent.testStepResult;
|
|
340
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri ===
|
|
341
|
-
const uri = doc
|
|
342
|
-
const feature = doc
|
|
333
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario?.uri);
|
|
334
|
+
const uri = doc?.uri;
|
|
335
|
+
const feature = doc?.feature;
|
|
343
336
|
/* istanbul ignore if */
|
|
344
337
|
if (!step) {
|
|
345
338
|
return;
|
|
@@ -357,8 +350,8 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
357
350
|
// }
|
|
358
351
|
// }
|
|
359
352
|
onTestCaseFinished(results) {
|
|
360
|
-
const tc = this._testCases.find(tc =>
|
|
361
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc
|
|
353
|
+
const tc = this._testCases.find(tc => tc.id === this._currentTestCase?.testCaseId);
|
|
354
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc?.pickleId));
|
|
362
355
|
/* istanbul ignore if */
|
|
363
356
|
if (!scenario) {
|
|
364
357
|
return;
|
|
@@ -366,12 +359,12 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
366
359
|
/**
|
|
367
360
|
* propagate the first non passing result or the last one
|
|
368
361
|
*/
|
|
369
|
-
const finalResult = results.find((r) => r.status !==
|
|
370
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri ===
|
|
371
|
-
const uri = doc
|
|
372
|
-
const feature = doc
|
|
362
|
+
const finalResult = results.find((r) => r.status !== Status.PASSED) || results.pop();
|
|
363
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario?.uri);
|
|
364
|
+
const uri = doc?.uri;
|
|
365
|
+
const feature = doc?.feature;
|
|
373
366
|
this._currentPickle = { uri, feature, scenario };
|
|
374
|
-
this.emit('after-scenario', doc
|
|
367
|
+
this.emit('after-scenario', doc?.uri, doc?.feature, scenario, finalResult);
|
|
375
368
|
}
|
|
376
369
|
// testRunFinishedEvent = {
|
|
377
370
|
// "timestamp": {
|
|
@@ -405,7 +398,7 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
405
398
|
/**
|
|
406
399
|
* match based on capability tags
|
|
407
400
|
*/
|
|
408
|
-
.filter(([, fakeId]) =>
|
|
401
|
+
.filter(([, fakeId]) => filterPickles(caps, this._scenarios.find(s => s.id === fakeId)))
|
|
409
402
|
/**
|
|
410
403
|
* match based on Cucumber pickle filter
|
|
411
404
|
*/
|
|
@@ -416,4 +409,3 @@ class CucumberEventListener extends events_1.EventEmitter {
|
|
|
416
409
|
.map(([id]) => id);
|
|
417
410
|
}
|
|
418
411
|
}
|
|
419
|
-
exports.default = CucumberEventListener;
|
package/build/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
4
3
|
import * as Cucumber from '@cucumber/cucumber';
|
|
5
4
|
import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
|
|
6
5
|
import { Long } from 'long';
|
|
7
6
|
import type { Capabilities, Options } from '@wdio/types';
|
|
8
|
-
import type
|
|
9
|
-
import { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types';
|
|
7
|
+
import type { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types';
|
|
10
8
|
declare class CucumberAdapter {
|
|
11
9
|
private _cid;
|
|
12
10
|
private _config;
|
|
@@ -41,9 +39,9 @@ declare class CucumberAdapter {
|
|
|
41
39
|
* Or pass your own function
|
|
42
40
|
* Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
|
|
43
41
|
*/
|
|
44
|
-
registerRequiredModules(): void;
|
|
42
|
+
registerRequiredModules(): Promise<void>[];
|
|
45
43
|
requiredFiles(): string[];
|
|
46
|
-
loadSpecFiles(): void
|
|
44
|
+
loadSpecFiles(): Promise<void>;
|
|
47
45
|
/**
|
|
48
46
|
* set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
|
|
49
47
|
* @param {object} config config
|
|
@@ -78,10 +76,5 @@ declare global {
|
|
|
78
76
|
interface HookFunctionExtension extends HookFunctionExtensionImport {
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
|
-
namespace NodeJS {
|
|
82
|
-
interface Global {
|
|
83
|
-
expect: ExpectWebdriverIO.Expect;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
79
|
}
|
|
87
80
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACH,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,EACL,IAAI,EACJ,IAAI,EACP,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAI3B,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAc,MAAM,aAAa,CAAA;AAKpE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,IAAI,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAgB3H,cAAM,eAAe;IAoBb,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IAvBrB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,gCAAgC,CAAU;IAClD,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,aAAa,CAAuB;IAE5C,aAAa,CAAC,EAAE,QAAQ,CAAA;IAExB;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,CAAA;gBAGA,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,CAAC,UAAU,EAC3B,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,YAAY,CAAC,gBAAgB,EAC5C,SAAS,EAAE,YAAY;IAiC7B,IAAI;IAyBV,QAAQ;IAIF,GAAG;IAkET;;;;;;;;OAQG;IACH,uBAAuB;IAYvB,aAAa;IAUP,aAAa;IAsBnB;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU;IAkDvC;;;OAGG;IACH,SAAS,CAAE,MAAM,EAAE,OAAO,CAAC,UAAU;IAwBrC;;;;;;;;;OASG;IACH,QAAQ,CACJ,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,OAAO,CAAC,UAAU,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,EAC9B,aAAa,EAAE,QAAQ,UAEA,cAAc,WAAW,GAAG,EAAE;CAkB5D;AAGD,QAAA,MAAM,cAAc,EAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAO,CAAA;AAa9C,eAAe,cAAc,CAAA;AAC7B,OAAO,EACH,eAAe,EACf,cAAc,EACd,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,KAAK,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,mBAAmB,EACnB,IAAI,EACJ,IAAI,EACJ,KAAK,EACR,CAAA;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,YAAa,SAAQ,eAAe;SAAG;QACjD,UAAU,qBAAsB,SAAQ,2BAA2B;SAAG;KACzE;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -1,69 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.World = exports.When = exports.Then = exports.setWorldConstructor = exports.setDefinitionFunctionWrapper = exports.setDefaultTimeout = exports.Given = exports.defineStep = exports.defineParameterType = exports.DataTable = exports.BeforeStep = exports.BeforeAll = exports.Before = exports.AfterStep = exports.AfterAll = exports.After = exports.adapterFactory = exports.CucumberAdapter = void 0;
|
|
30
|
-
const path_1 = __importDefault(require("path"));
|
|
31
|
-
const events_1 = require("events");
|
|
32
|
-
const mockery_1 = __importDefault(require("mockery"));
|
|
33
|
-
const is_glob_1 = __importDefault(require("is-glob"));
|
|
34
|
-
const glob_1 = __importDefault(require("glob"));
|
|
35
|
-
const Cucumber = __importStar(require("@cucumber/cucumber"));
|
|
36
|
-
const cucumber_1 = require("@cucumber/cucumber");
|
|
37
|
-
Object.defineProperty(exports, "After", { enumerable: true, get: function () { return cucumber_1.After; } });
|
|
38
|
-
Object.defineProperty(exports, "AfterAll", { enumerable: true, get: function () { return cucumber_1.AfterAll; } });
|
|
39
|
-
Object.defineProperty(exports, "AfterStep", { enumerable: true, get: function () { return cucumber_1.AfterStep; } });
|
|
40
|
-
Object.defineProperty(exports, "Before", { enumerable: true, get: function () { return cucumber_1.Before; } });
|
|
41
|
-
Object.defineProperty(exports, "BeforeAll", { enumerable: true, get: function () { return cucumber_1.BeforeAll; } });
|
|
42
|
-
Object.defineProperty(exports, "BeforeStep", { enumerable: true, get: function () { return cucumber_1.BeforeStep; } });
|
|
43
|
-
Object.defineProperty(exports, "DataTable", { enumerable: true, get: function () { return cucumber_1.DataTable; } });
|
|
44
|
-
Object.defineProperty(exports, "defineParameterType", { enumerable: true, get: function () { return cucumber_1.defineParameterType; } });
|
|
45
|
-
Object.defineProperty(exports, "defineStep", { enumerable: true, get: function () { return cucumber_1.defineStep; } });
|
|
46
|
-
Object.defineProperty(exports, "Given", { enumerable: true, get: function () { return cucumber_1.Given; } });
|
|
47
|
-
Object.defineProperty(exports, "setDefaultTimeout", { enumerable: true, get: function () { return cucumber_1.setDefaultTimeout; } });
|
|
48
|
-
Object.defineProperty(exports, "setDefinitionFunctionWrapper", { enumerable: true, get: function () { return cucumber_1.setDefinitionFunctionWrapper; } });
|
|
49
|
-
Object.defineProperty(exports, "setWorldConstructor", { enumerable: true, get: function () { return cucumber_1.setWorldConstructor; } });
|
|
50
|
-
Object.defineProperty(exports, "World", { enumerable: true, get: function () { return cucumber_1.World; } });
|
|
51
|
-
Object.defineProperty(exports, "Then", { enumerable: true, get: function () { return cucumber_1.Then; } });
|
|
52
|
-
Object.defineProperty(exports, "When", { enumerable: true, get: function () { return cucumber_1.When; } });
|
|
53
|
-
const gherkin_streams_1 = require("@cucumber/gherkin-streams");
|
|
54
|
-
const event_data_collector_1 = __importDefault(require("@cucumber/cucumber/lib/formatter/helpers/event_data_collector"));
|
|
55
|
-
const messages_1 = require("@cucumber/messages");
|
|
56
|
-
const utils_1 = require("@wdio/utils");
|
|
57
|
-
const reporter_1 = __importDefault(require("./reporter"));
|
|
58
|
-
const constants_1 = require("./constants");
|
|
59
|
-
const utils_2 = require("./utils");
|
|
60
|
-
const { incrementing } = messages_1.IdGenerator;
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
import mockery from 'mockery';
|
|
5
|
+
import isGlob from 'is-glob';
|
|
6
|
+
import glob from 'glob';
|
|
7
|
+
import * as Cucumber from '@cucumber/cucumber';
|
|
8
|
+
import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
|
|
9
|
+
import { GherkinStreams } from '@cucumber/gherkin-streams';
|
|
10
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
11
|
+
import { executeHooksWithArgs, testFnWrapper } from '@wdio/utils';
|
|
12
|
+
import CucumberReporter from './reporter.js';
|
|
13
|
+
import { DEFAULT_OPTS } from './constants.js';
|
|
14
|
+
import { setUserHookNames } from './utils.js';
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const EventDataCollector = require('@cucumber/cucumber/lib/formatter/helpers/event_data_collector').default;
|
|
17
|
+
const FILE_PROTOCOL = 'file://';
|
|
18
|
+
const { incrementing } = IdGenerator;
|
|
61
19
|
function getResultObject(world) {
|
|
62
|
-
var _a, _b, _c, _d, _e;
|
|
63
20
|
return {
|
|
64
|
-
passed: (
|
|
65
|
-
error:
|
|
66
|
-
duration:
|
|
21
|
+
passed: (world.result?.status === Cucumber.Status.PASSED || world.result?.status === Cucumber.Status.SKIPPED),
|
|
22
|
+
error: world.result?.message,
|
|
23
|
+
duration: world.result?.duration?.nanos / 1e6 // convert into ms
|
|
67
24
|
};
|
|
68
25
|
}
|
|
69
26
|
class CucumberAdapter {
|
|
@@ -75,12 +32,17 @@ class CucumberAdapter {
|
|
|
75
32
|
this._reporter = _reporter;
|
|
76
33
|
this._cwd = process.cwd();
|
|
77
34
|
this._newId = incrementing();
|
|
78
|
-
this._cucumberOpts = Object.assign({},
|
|
35
|
+
this._cucumberOpts = Object.assign({}, DEFAULT_OPTS, this._config.cucumberOpts);
|
|
79
36
|
this._hasTests = true;
|
|
80
37
|
this._cucumberFeaturesWithLineNumbers = this._config.cucumberFeaturesWithLineNumbers || [];
|
|
81
|
-
this._eventBroadcaster = new
|
|
82
|
-
this._eventDataCollector = new
|
|
83
|
-
|
|
38
|
+
this._eventBroadcaster = new EventEmitter();
|
|
39
|
+
this._eventDataCollector = new EventDataCollector(this._eventBroadcaster);
|
|
40
|
+
this._specs = this._specs.map((spec) => (spec.startsWith(FILE_PROTOCOL)
|
|
41
|
+
? spec.slice(FILE_PROTOCOL.length)
|
|
42
|
+
: spec));
|
|
43
|
+
const featurePathsToRun = this._cucumberFeaturesWithLineNumbers.length > 0
|
|
44
|
+
? this._cucumberFeaturesWithLineNumbers
|
|
45
|
+
: this._specs;
|
|
84
46
|
this._pickleFilter = new Cucumber.PickleFilter({
|
|
85
47
|
cwd: this._cwd,
|
|
86
48
|
featurePaths: featurePathsToRun,
|
|
@@ -94,11 +56,11 @@ class CucumberAdapter {
|
|
|
94
56
|
tagsInTitle: Boolean(this._cucumberOpts.tagsInTitle),
|
|
95
57
|
scenarioLevelReporter: Boolean(this._cucumberOpts.scenarioLevelReporter)
|
|
96
58
|
};
|
|
97
|
-
this._cucumberReporter = new
|
|
59
|
+
this._cucumberReporter = new CucumberReporter(this._eventBroadcaster, this._pickleFilter, reporterOptions, this._cid, this._specs, this._reporter);
|
|
98
60
|
}
|
|
99
61
|
async init() {
|
|
100
62
|
try {
|
|
101
|
-
const gherkinMessageStream =
|
|
63
|
+
const gherkinMessageStream = GherkinStreams.fromPaths(this._specs, {
|
|
102
64
|
defaultDialect: this._cucumberOpts.featureDefaultLanguage,
|
|
103
65
|
newId: this._newId
|
|
104
66
|
});
|
|
@@ -113,18 +75,9 @@ class CucumberAdapter {
|
|
|
113
75
|
this._hasTests = this._cucumberReporter.eventListener.getPickleIds(this._capabilities).length > 0;
|
|
114
76
|
}
|
|
115
77
|
catch (runtimeError) {
|
|
116
|
-
await
|
|
78
|
+
await executeHooksWithArgs('after', this._config.after, [runtimeError, this._capabilities, this._specs]);
|
|
117
79
|
throw runtimeError;
|
|
118
80
|
}
|
|
119
|
-
/**
|
|
120
|
-
* import and set options for `expect-webdriverio` assertion lib once
|
|
121
|
-
* the framework was initiated so that it can detect the environment
|
|
122
|
-
*/
|
|
123
|
-
const { setOptions } = require('expect-webdriverio');
|
|
124
|
-
setOptions({
|
|
125
|
-
wait: this._config.waitforTimeout,
|
|
126
|
-
interval: this._config.waitforInterval, // interval between attempts
|
|
127
|
-
});
|
|
128
81
|
return this;
|
|
129
82
|
}
|
|
130
83
|
hasTests() {
|
|
@@ -134,19 +87,19 @@ class CucumberAdapter {
|
|
|
134
87
|
let runtimeError;
|
|
135
88
|
let result;
|
|
136
89
|
try {
|
|
137
|
-
this.registerRequiredModules();
|
|
90
|
+
await this.registerRequiredModules();
|
|
138
91
|
Cucumber.supportCodeLibraryBuilder.reset(this._cwd, this._newId);
|
|
139
92
|
/**
|
|
140
93
|
* wdio hooks should be added before spec files are loaded
|
|
141
94
|
*/
|
|
142
95
|
this.addWdioHooks(this._config);
|
|
143
|
-
this.loadSpecFiles();
|
|
96
|
+
await this.loadSpecFiles();
|
|
144
97
|
this.wrapSteps(this._config);
|
|
145
98
|
/**
|
|
146
99
|
* we need to somehow identify is function is step or hook
|
|
147
100
|
* so we wrap every user hook function
|
|
148
101
|
*/
|
|
149
|
-
|
|
102
|
+
setUserHookNames(Cucumber.supportCodeLibraryBuilder);
|
|
150
103
|
Cucumber.setDefaultTimeout(this._cucumberOpts.timeout);
|
|
151
104
|
const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize();
|
|
152
105
|
/**
|
|
@@ -178,7 +131,7 @@ class CucumberAdapter {
|
|
|
178
131
|
runtimeError = err;
|
|
179
132
|
result = 1;
|
|
180
133
|
}
|
|
181
|
-
await
|
|
134
|
+
await executeHooksWithArgs('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
|
|
182
135
|
/**
|
|
183
136
|
* in case the spec has a runtime error throw after the wdio hook
|
|
184
137
|
*/
|
|
@@ -197,71 +150,70 @@ class CucumberAdapter {
|
|
|
197
150
|
* Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
|
|
198
151
|
*/
|
|
199
152
|
registerRequiredModules() {
|
|
200
|
-
this._cucumberOpts.requireModule.map(requiredModule => {
|
|
153
|
+
return this._cucumberOpts.requireModule.map(async (requiredModule) => {
|
|
201
154
|
if (Array.isArray(requiredModule)) {
|
|
202
|
-
|
|
155
|
+
(await import(requiredModule[0]))(requiredModule[1]);
|
|
203
156
|
}
|
|
204
157
|
else if (typeof requiredModule === 'function') {
|
|
205
158
|
requiredModule();
|
|
206
159
|
}
|
|
207
160
|
else {
|
|
208
|
-
|
|
161
|
+
await import(requiredModule);
|
|
209
162
|
}
|
|
210
163
|
});
|
|
211
164
|
}
|
|
212
165
|
requiredFiles() {
|
|
213
|
-
return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat((
|
|
214
|
-
?
|
|
166
|
+
return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat(isGlob(requiredFile)
|
|
167
|
+
? glob.sync(requiredFile)
|
|
215
168
|
: [requiredFile]), []);
|
|
216
169
|
}
|
|
217
|
-
loadSpecFiles() {
|
|
170
|
+
async loadSpecFiles() {
|
|
218
171
|
// we use mockery to allow people to import 'our' cucumber even though their spec files are in their folders
|
|
219
172
|
// because of that we don't have to attach anything to the global object, and the current cucumber spec files
|
|
220
173
|
// should just work with no changes with this framework
|
|
221
|
-
|
|
174
|
+
mockery.enable({
|
|
222
175
|
useCleanCache: false,
|
|
223
176
|
warnOnReplace: false,
|
|
224
177
|
warnOnUnregistered: false
|
|
225
178
|
});
|
|
226
|
-
|
|
227
|
-
this.requiredFiles().
|
|
228
|
-
const filepath =
|
|
179
|
+
mockery.registerMock('@cucumber/cucumber', Cucumber);
|
|
180
|
+
await Promise.all(this.requiredFiles().map((codePath) => {
|
|
181
|
+
const filepath = path.isAbsolute(codePath)
|
|
229
182
|
? codePath
|
|
230
|
-
:
|
|
183
|
+
: path.join(process.cwd(), codePath);
|
|
231
184
|
// This allows rerunning a stepDefinitions file
|
|
232
185
|
delete require.cache[require.resolve(filepath)];
|
|
233
|
-
|
|
234
|
-
});
|
|
235
|
-
|
|
186
|
+
return import(filepath);
|
|
187
|
+
}));
|
|
188
|
+
mockery.disable();
|
|
236
189
|
}
|
|
237
190
|
/**
|
|
238
191
|
* set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
|
|
239
192
|
* @param {object} config config
|
|
240
193
|
*/
|
|
241
194
|
addWdioHooks(config) {
|
|
242
|
-
|
|
243
|
-
const eventListener = (_a = this._cucumberReporter) === null || _a === void 0 ? void 0 : _a.eventListener;
|
|
195
|
+
const eventListener = this._cucumberReporter?.eventListener;
|
|
244
196
|
Cucumber.BeforeAll(async function wdioHookBeforeFeature() {
|
|
245
|
-
const params = eventListener
|
|
246
|
-
await
|
|
197
|
+
const params = eventListener?.getHookParams();
|
|
198
|
+
await executeHooksWithArgs('beforeFeature', config.beforeFeature, [params?.uri, params?.feature]);
|
|
247
199
|
});
|
|
248
200
|
Cucumber.AfterAll(async function wdioHookAfterFeature() {
|
|
249
|
-
const params = eventListener
|
|
250
|
-
await
|
|
201
|
+
const params = eventListener?.getHookParams();
|
|
202
|
+
await executeHooksWithArgs('afterFeature', config.afterFeature, [params?.uri, params?.feature]);
|
|
251
203
|
});
|
|
252
204
|
Cucumber.Before(async function wdioHookBeforeScenario(world) {
|
|
253
|
-
await
|
|
205
|
+
await executeHooksWithArgs('beforeScenario', config.beforeScenario, [world, this]);
|
|
254
206
|
});
|
|
255
207
|
Cucumber.After(async function wdioHookAfterScenario(world) {
|
|
256
|
-
await
|
|
208
|
+
await executeHooksWithArgs('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
|
|
257
209
|
});
|
|
258
210
|
Cucumber.BeforeStep(async function wdioHookBeforeStep() {
|
|
259
|
-
const params = eventListener
|
|
260
|
-
await
|
|
211
|
+
const params = eventListener?.getHookParams();
|
|
212
|
+
await executeHooksWithArgs('beforeStep', config.beforeStep, [params?.step, params?.scenario, this]);
|
|
261
213
|
});
|
|
262
214
|
Cucumber.AfterStep(async function wdioHookAfterStep(world) {
|
|
263
|
-
const params = eventListener
|
|
264
|
-
await
|
|
215
|
+
const params = eventListener?.getHookParams();
|
|
216
|
+
await executeHooksWithArgs('afterStep', config.afterStep, [params?.step, params?.scenario, getResultObject(world), this]);
|
|
265
217
|
});
|
|
266
218
|
}
|
|
267
219
|
/**
|
|
@@ -307,14 +259,12 @@ class CucumberAdapter {
|
|
|
307
259
|
*/
|
|
308
260
|
const beforeFn = config.beforeHook;
|
|
309
261
|
const afterFn = config.afterHook;
|
|
310
|
-
return
|
|
262
|
+
return testFnWrapper.call(this, isStep ? 'Step' : 'Hook', { specFn: code, specFnArgs: args }, { beforeFn: beforeFn, beforeFnArgs: (context) => [hookParams?.step, context] }, { afterFn: afterFn, afterFnArgs: (context) => [hookParams?.step, context] }, cid, retryTest);
|
|
311
263
|
};
|
|
312
264
|
}
|
|
313
265
|
}
|
|
314
|
-
exports.CucumberAdapter = CucumberAdapter;
|
|
315
266
|
const _CucumberAdapter = CucumberAdapter;
|
|
316
267
|
const adapterFactory = {};
|
|
317
|
-
exports.adapterFactory = adapterFactory;
|
|
318
268
|
/**
|
|
319
269
|
* tested by smoke tests
|
|
320
270
|
*/
|
|
@@ -325,4 +275,5 @@ adapterFactory.init = async function (...args) {
|
|
|
325
275
|
const instance = await adapter.init();
|
|
326
276
|
return instance;
|
|
327
277
|
};
|
|
328
|
-
|
|
278
|
+
export default adapterFactory;
|
|
279
|
+
export { CucumberAdapter, adapterFactory, After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, Then, When, World };
|
package/build/reporter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { PickleFilter } from '@cucumber/cucumber';
|
|
4
4
|
import { Feature, Pickle, PickleStep, TestStep, TestStepResult } from '@cucumber/messages';
|
|
5
|
-
import CucumberEventListener from './cucumberEventListener';
|
|
5
|
+
import CucumberEventListener from './cucumberEventListener.js';
|
|
6
|
+
import { ReporterScenario } from './constants.js';
|
|
6
7
|
import type { ReporterOptions } from './types';
|
|
7
|
-
|
|
8
|
-
declare class CucumberReporter {
|
|
8
|
+
export default class CucumberReporter {
|
|
9
9
|
private _options;
|
|
10
10
|
private _cid;
|
|
11
11
|
private _specs;
|
|
@@ -29,5 +29,4 @@ declare class CucumberReporter {
|
|
|
29
29
|
emit(event: string, payload: any): void;
|
|
30
30
|
getTitle(featureOrScenario: Feature | Pickle): string;
|
|
31
31
|
}
|
|
32
|
-
export default CucumberReporter;
|
|
33
32
|
//# sourceMappingURL=reporter.d.ts.map
|
package/build/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAU,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAoC,MAAM,oBAAoB,CAAA;AAE5H,OAAO,qBAAqB,MAAM,4BAA4B,CAAA;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAa7B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;IAfd,aAAa,EAAE,qBAAqB,CAAA;IACpC,WAAW,SAAI;IAEtB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,aAAa,CAAC,CAAM;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAM;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAM;gBAGrB,gBAAgB,EAAE,YAAY,EAC9B,YAAY,EAAE,YAAY,EAClB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,EAAE,YAAY;IAkBnC,mBAAmB,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAclD,oBAAoB,CAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,gBAAgB;IAgB9B,gBAAgB,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GAAG,QAAQ;IAS/B,eAAe,CACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GAAG,QAAQ,EAC3B,MAAM,EAAE,cAAc;IAS1B,SAAS,CACL,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,cAAc;IAkB1B,SAAS,CACL,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,cAAc;IA+F1B,mBAAmB,CACf,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc;IAiB1B,kBAAkB,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAWjD,IAAI,CAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG;IAUjC,QAAQ,CAAE,iBAAiB,EAAE,OAAO,GAAG,MAAM;CAMhD"}
|
package/build/reporter.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cucumber_1 = require("@cucumber/cucumber");
|
|
7
|
-
const cucumberEventListener_1 = __importDefault(require("./cucumberEventListener"));
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
class CucumberReporter {
|
|
1
|
+
import { Status } from '@cucumber/cucumber';
|
|
2
|
+
import CucumberEventListener from './cucumberEventListener.js';
|
|
3
|
+
import { getFeatureId, formatMessage, getStepType, buildStepPayload } from './utils.js';
|
|
4
|
+
export default class CucumberReporter {
|
|
10
5
|
constructor(eventBroadcaster, pickleFilter, _options, _cid, _specs, _reporter) {
|
|
11
6
|
this._options = _options;
|
|
12
7
|
this._cid = _cid;
|
|
@@ -15,7 +10,7 @@ class CucumberReporter {
|
|
|
15
10
|
this.failedCount = 0;
|
|
16
11
|
this._tagsInTitle = this._options.tagsInTitle || false;
|
|
17
12
|
this._scenarioLevelReport = this._options.scenarioLevelReporter;
|
|
18
|
-
this.eventListener = new
|
|
13
|
+
this.eventListener = new CucumberEventListener(eventBroadcaster, pickleFilter)
|
|
19
14
|
.on('before-feature', this.handleBeforeFeature.bind(this))
|
|
20
15
|
.on('before-scenario', this.handleBeforeScenario.bind(this))
|
|
21
16
|
.on('after-scenario', this.handleAfterScenario.bind(this))
|
|
@@ -29,7 +24,7 @@ class CucumberReporter {
|
|
|
29
24
|
handleBeforeFeature(uri, feature) {
|
|
30
25
|
this._featureStart = new Date();
|
|
31
26
|
this.emit('suite:start', {
|
|
32
|
-
uid:
|
|
27
|
+
uid: getFeatureId(uri, feature),
|
|
33
28
|
title: this.getTitle(feature),
|
|
34
29
|
type: 'feature',
|
|
35
30
|
file: uri,
|
|
@@ -44,7 +39,7 @@ class CucumberReporter {
|
|
|
44
39
|
this.emit(this._scenarioLevelReport ? 'test:start' : 'suite:start', {
|
|
45
40
|
uid: scenario.id,
|
|
46
41
|
title: this.getTitle(scenario),
|
|
47
|
-
parent:
|
|
42
|
+
parent: getFeatureId(uri, feature),
|
|
48
43
|
type: 'scenario',
|
|
49
44
|
file: uri,
|
|
50
45
|
tags: scenario.tags,
|
|
@@ -53,58 +48,56 @@ class CucumberReporter {
|
|
|
53
48
|
}
|
|
54
49
|
handleBeforeStep(uri, feature, scenario, step) {
|
|
55
50
|
this._testStart = new Date();
|
|
56
|
-
const type =
|
|
57
|
-
const payload =
|
|
51
|
+
const type = getStepType(step);
|
|
52
|
+
const payload = buildStepPayload(uri, feature, scenario, step, { type });
|
|
58
53
|
this.emit(`${type}:start`, payload);
|
|
59
54
|
}
|
|
60
55
|
handleAfterStep(uri, feature, scenario, step, result) {
|
|
61
|
-
const type =
|
|
56
|
+
const type = getStepType(step);
|
|
62
57
|
if (type === 'hook') {
|
|
63
58
|
return this.afterHook(uri, feature, scenario, step, result);
|
|
64
59
|
}
|
|
65
60
|
return this.afterTest(uri, feature, scenario, step, result);
|
|
66
61
|
}
|
|
67
62
|
afterHook(uri, feature, scenario, step, result) {
|
|
68
|
-
var _a;
|
|
69
63
|
let error;
|
|
70
64
|
if (result.message) {
|
|
71
65
|
error = new Error(result.message.split('\n')[0]);
|
|
72
66
|
error.stack = result.message;
|
|
73
67
|
}
|
|
74
|
-
const payload =
|
|
68
|
+
const payload = buildStepPayload(uri, feature, scenario, step, {
|
|
75
69
|
type: 'hook',
|
|
76
70
|
state: result.status,
|
|
77
71
|
error,
|
|
78
|
-
duration: Date.now() -
|
|
72
|
+
duration: Date.now() - this._testStart?.getTime()
|
|
79
73
|
});
|
|
80
74
|
this.emit('hook:end', payload);
|
|
81
75
|
}
|
|
82
76
|
afterTest(uri, feature, scenario, step, result) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
84
77
|
let state = 'undefined';
|
|
85
78
|
switch (result.status) {
|
|
86
|
-
case
|
|
87
|
-
case
|
|
79
|
+
case Status.FAILED:
|
|
80
|
+
case Status.UNDEFINED:
|
|
88
81
|
state = 'fail';
|
|
89
82
|
break;
|
|
90
|
-
case
|
|
83
|
+
case Status.PASSED:
|
|
91
84
|
state = 'pass';
|
|
92
85
|
break;
|
|
93
|
-
case
|
|
86
|
+
case Status.PENDING:
|
|
94
87
|
state = 'pending';
|
|
95
88
|
break;
|
|
96
|
-
case
|
|
89
|
+
case Status.SKIPPED:
|
|
97
90
|
state = 'skip';
|
|
98
91
|
break;
|
|
99
|
-
case
|
|
92
|
+
case Status.AMBIGUOUS:
|
|
100
93
|
state = 'pending';
|
|
101
94
|
break;
|
|
102
95
|
}
|
|
103
96
|
let error = result.message ? new Error(result.message) : undefined;
|
|
104
97
|
let title = step
|
|
105
|
-
? step
|
|
98
|
+
? step?.text
|
|
106
99
|
: this.getTitle(scenario);
|
|
107
|
-
if (result.status ===
|
|
100
|
+
if (result.status === Status.UNDEFINED) {
|
|
108
101
|
if (this._options.ignoreUndefinedDefinitions) {
|
|
109
102
|
/**
|
|
110
103
|
* mark test as pending
|
|
@@ -120,26 +113,26 @@ class CucumberReporter {
|
|
|
120
113
|
const err = new Error((step ? `Step "${title}" is not defined. ` : `Scenario ${title} has undefined steps. `) +
|
|
121
114
|
'You can ignore this error by setting cucumberOpts.ignoreUndefinedDefinitions as true.');
|
|
122
115
|
err.stack = `${err.message}\n\tat Feature(${uri}):1:1\n`;
|
|
123
|
-
const featChildren =
|
|
116
|
+
const featChildren = feature.children?.find(c => scenario.astNodeIds && c.scenario?.id === scenario.astNodeIds[0]);
|
|
124
117
|
if (featChildren) {
|
|
125
|
-
err.stack += `\tat Scenario(${
|
|
126
|
-
const featStep =
|
|
118
|
+
err.stack += `\tat Scenario(${featChildren.scenario?.name}):${featChildren.scenario?.location?.line}:${featChildren.scenario?.location?.column}\n`;
|
|
119
|
+
const featStep = featChildren.scenario?.steps?.find(s => step.astNodeIds && s.id === step.astNodeIds[0]);
|
|
127
120
|
if (featStep) {
|
|
128
|
-
err.stack += `\tat Step(${featStep.text}):${
|
|
121
|
+
err.stack += `\tat Step(${featStep.text}):${featStep.location?.line}:${featStep.location?.column}\n`;
|
|
129
122
|
}
|
|
130
123
|
}
|
|
131
124
|
error = err;
|
|
132
125
|
}
|
|
133
126
|
}
|
|
134
|
-
else if (result.status ===
|
|
135
|
-
error = new Error(
|
|
127
|
+
else if (result.status === Status.FAILED && !result.willBeRetried) {
|
|
128
|
+
error = new Error(result.message?.split('\n')[0]);
|
|
136
129
|
error.stack = result.message;
|
|
137
130
|
this.failedCount++;
|
|
138
131
|
}
|
|
139
|
-
else if (result.status ===
|
|
132
|
+
else if (result.status === Status.AMBIGUOUS && this._options.failAmbiguousDefinitions) {
|
|
140
133
|
state = 'fail';
|
|
141
134
|
this.failedCount++;
|
|
142
|
-
error = new Error(
|
|
135
|
+
error = new Error(result.message?.split('\n')[0]);
|
|
143
136
|
error.stack = result.message;
|
|
144
137
|
}
|
|
145
138
|
else if (result.willBeRetried) {
|
|
@@ -149,52 +142,50 @@ class CucumberReporter {
|
|
|
149
142
|
title: title,
|
|
150
143
|
state,
|
|
151
144
|
error,
|
|
152
|
-
duration: Date.now() -
|
|
145
|
+
duration: Date.now() - this._testStart?.getTime(),
|
|
153
146
|
passed: ['pass', 'skip'].includes(state),
|
|
154
147
|
file: uri
|
|
155
148
|
};
|
|
156
149
|
const payload = step
|
|
157
|
-
?
|
|
150
|
+
? buildStepPayload(uri, feature, scenario, step, {
|
|
158
151
|
type: 'step',
|
|
159
152
|
...common
|
|
160
153
|
})
|
|
161
154
|
: {
|
|
162
155
|
type: 'scenario',
|
|
163
156
|
uid: scenario.id,
|
|
164
|
-
parent:
|
|
157
|
+
parent: getFeatureId(uri, feature),
|
|
165
158
|
tags: scenario.tags,
|
|
166
159
|
...common
|
|
167
160
|
};
|
|
168
161
|
this.emit('test:' + state, payload);
|
|
169
162
|
}
|
|
170
163
|
handleAfterScenario(uri, feature, scenario, result) {
|
|
171
|
-
var _a;
|
|
172
164
|
if (this._scenarioLevelReport) {
|
|
173
165
|
return this.afterTest(uri, feature, scenario, { id: scenario.id }, result);
|
|
174
166
|
}
|
|
175
167
|
this.emit('suite:end', {
|
|
176
168
|
uid: scenario.id,
|
|
177
169
|
title: this.getTitle(scenario),
|
|
178
|
-
parent:
|
|
170
|
+
parent: getFeatureId(uri, feature),
|
|
179
171
|
type: 'scenario',
|
|
180
172
|
file: uri,
|
|
181
|
-
duration: Date.now() -
|
|
173
|
+
duration: Date.now() - this._scenarioStart?.getTime(),
|
|
182
174
|
tags: scenario.tags
|
|
183
175
|
});
|
|
184
176
|
}
|
|
185
177
|
handleAfterFeature(uri, feature) {
|
|
186
|
-
var _a;
|
|
187
178
|
this.emit('suite:end', {
|
|
188
|
-
uid:
|
|
179
|
+
uid: getFeatureId(uri, feature),
|
|
189
180
|
title: this.getTitle(feature),
|
|
190
181
|
type: 'feature',
|
|
191
182
|
file: uri,
|
|
192
|
-
duration: Date.now() -
|
|
183
|
+
duration: Date.now() - this._featureStart?.getTime(),
|
|
193
184
|
tags: feature.tags
|
|
194
185
|
});
|
|
195
186
|
}
|
|
196
187
|
emit(event, payload) {
|
|
197
|
-
let message =
|
|
188
|
+
let message = formatMessage({ payload });
|
|
198
189
|
message.cid = this._cid;
|
|
199
190
|
message.specs = this._specs;
|
|
200
191
|
message.uid = payload.uid;
|
|
@@ -208,4 +199,3 @@ class CucumberReporter {
|
|
|
208
199
|
return `${tags.map((tag) => tag.name).join(', ')}: ${name}`;
|
|
209
200
|
}
|
|
210
201
|
}
|
|
211
|
-
exports.default = CucumberReporter;
|
package/build/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/build/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { supportCodeLibraryBuilder } from '@cucumber/cucumber';
|
|
2
2
|
import { PickleStep, TestStep, Feature, Pickle, TestStepResultStatus } from '@cucumber/messages';
|
|
3
|
-
import { Capabilities } from '@wdio/types';
|
|
4
|
-
import { ReporterStep } from './constants';
|
|
3
|
+
import type { Capabilities } from '@wdio/types';
|
|
4
|
+
import { ReporterStep } from './constants.js';
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: this function is exported for testing only
|
|
7
7
|
*/
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAuB,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACrH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAuB,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACrH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAkC,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK7E;;GAEG;AACH,wBAAgB,kBAAkB,CAAE,EAAE,QAAQ,EAAE,EAAE,UAAU;;;;cAoB3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAE,EAAE,OAAY,EAAE,EAAE,GAAG,OAgBnD;AAED,aAAK,QAAQ;IACT,IAAI,SAAS;IACb,IAAI,SAAS;CAChB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,EAAE,QAAQ,YAE1C;AAED,wBAAgB,YAAY,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,UAE1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,oBAAY,EAAE,IAAI,oBAAY,EAAE,IAAI,EAAC,MAAM,UAGnF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,oBAAoB,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5C,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;;;;;;;;;;;;;UAPS,MAAM;;;;;EAqBnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,OAAO,yBAAyB,QAe1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAE,YAAY,EAAE,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,WA+B1F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAS3D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,kBA4BvE"}
|
package/build/utils.js
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.addKeywordToStep = exports.getRule = exports.filterPickles = exports.setUserHookNames = exports.buildStepPayload = exports.getTestStepTitle = exports.getFeatureId = exports.getStepType = exports.formatMessage = exports.createStepArgument = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const utils_1 = require("@wdio/utils");
|
|
9
|
-
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
|
-
const log = (0, logger_1.default)('@wdio/cucumber-framework:utils');
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import logger from '@wdio/logger';
|
|
3
|
+
import { isFunctionAsync } from '@wdio/utils';
|
|
4
|
+
import { CUCUMBER_HOOK_DEFINITION_TYPES } from './constants.js';
|
|
5
|
+
const log = logger('@wdio/cucumber-framework:utils');
|
|
12
6
|
/**
|
|
13
7
|
* NOTE: this function is exported for testing only
|
|
14
8
|
*/
|
|
15
|
-
function createStepArgument({ argument }) {
|
|
16
|
-
var _a;
|
|
9
|
+
export function createStepArgument({ argument }) {
|
|
17
10
|
if (!argument) {
|
|
18
11
|
return undefined;
|
|
19
12
|
}
|
|
20
13
|
if (argument.dataTable) {
|
|
21
14
|
return {
|
|
22
|
-
rows:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
cells: (_a = row.cells) === null || _a === void 0 ? void 0 : _a.map((cell) => cell.value)
|
|
26
|
-
});
|
|
27
|
-
})
|
|
15
|
+
rows: argument.dataTable.rows?.map((row) => ({
|
|
16
|
+
cells: row.cells?.map((cell) => cell.value)
|
|
17
|
+
}))
|
|
28
18
|
};
|
|
29
19
|
}
|
|
30
20
|
if (argument.docString) {
|
|
@@ -32,12 +22,11 @@ function createStepArgument({ argument }) {
|
|
|
32
22
|
}
|
|
33
23
|
return undefined;
|
|
34
24
|
}
|
|
35
|
-
exports.createStepArgument = createStepArgument;
|
|
36
25
|
/**
|
|
37
26
|
* format message
|
|
38
27
|
* @param {object} message { type: string, payload: object }
|
|
39
28
|
*/
|
|
40
|
-
function formatMessage({ payload = {} }) {
|
|
29
|
+
export function formatMessage({ payload = {} }) {
|
|
41
30
|
let content = { ...payload };
|
|
42
31
|
/**
|
|
43
32
|
* need to convert Error to plain object, otherwise it is lost on process.send
|
|
@@ -51,7 +40,6 @@ function formatMessage({ payload = {} }) {
|
|
|
51
40
|
}
|
|
52
41
|
return content;
|
|
53
42
|
}
|
|
54
|
-
exports.formatMessage = formatMessage;
|
|
55
43
|
var StepType;
|
|
56
44
|
(function (StepType) {
|
|
57
45
|
StepType["hook"] = "hook";
|
|
@@ -61,30 +49,26 @@ var StepType;
|
|
|
61
49
|
* Get step type
|
|
62
50
|
* @param {string} type `Step` or `Hook`
|
|
63
51
|
*/
|
|
64
|
-
function getStepType(step) {
|
|
52
|
+
export function getStepType(step) {
|
|
65
53
|
return step.hookId ? StepType.hook : StepType.test;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var _a, _b;
|
|
70
|
-
return `${path_1.default.basename(uri)}:${(_a = feature.location) === null || _a === void 0 ? void 0 : _a.line}:${(_b = feature.location) === null || _b === void 0 ? void 0 : _b.column}`;
|
|
55
|
+
export function getFeatureId(uri, feature) {
|
|
56
|
+
return `${path.basename(uri)}:${feature.location?.line}:${feature.location?.column}`;
|
|
71
57
|
}
|
|
72
|
-
exports.getFeatureId = getFeatureId;
|
|
73
58
|
/**
|
|
74
59
|
* Builds test title from step keyword and text
|
|
75
60
|
* @param {string} keyword
|
|
76
61
|
* @param {string} text
|
|
77
62
|
* @param {string} type
|
|
78
63
|
*/
|
|
79
|
-
function getTestStepTitle(keyword = '', text = '', type) {
|
|
64
|
+
export function getTestStepTitle(keyword = '', text = '', type) {
|
|
80
65
|
const title = (!text && type.toLowerCase() !== 'hook') ? 'Undefined Step' : text;
|
|
81
66
|
return `${keyword.trim()} ${title.trim()}`.trim();
|
|
82
67
|
}
|
|
83
|
-
exports.getTestStepTitle = getTestStepTitle;
|
|
84
68
|
/**
|
|
85
69
|
* build payload for test/hook event
|
|
86
70
|
*/
|
|
87
|
-
function buildStepPayload(uri, feature, scenario, step, params) {
|
|
71
|
+
export function buildStepPayload(uri, feature, scenario, step, params) {
|
|
88
72
|
return {
|
|
89
73
|
...params,
|
|
90
74
|
uid: step.id,
|
|
@@ -98,14 +82,13 @@ function buildStepPayload(uri, feature, scenario, step, params) {
|
|
|
98
82
|
scenarioName: scenario.name,
|
|
99
83
|
};
|
|
100
84
|
}
|
|
101
|
-
exports.buildStepPayload = buildStepPayload;
|
|
102
85
|
/**
|
|
103
86
|
* wrap every user defined hook with function named `userHookFn`
|
|
104
87
|
* to identify later on is function a step, user hook or wdio hook.
|
|
105
88
|
* @param {object} options `Cucumber.supportCodeLibraryBuilder.options`
|
|
106
89
|
*/
|
|
107
|
-
function setUserHookNames(options) {
|
|
108
|
-
|
|
90
|
+
export function setUserHookNames(options) {
|
|
91
|
+
CUCUMBER_HOOK_DEFINITION_TYPES.forEach(hookName => {
|
|
109
92
|
options[hookName].forEach((testRunHookDefinition) => {
|
|
110
93
|
const hookFn = testRunHookDefinition.code;
|
|
111
94
|
if (!hookFn.name.startsWith('wdioHook')) {
|
|
@@ -115,19 +98,18 @@ function setUserHookNames(options) {
|
|
|
115
98
|
const userHookFn = function (...args) {
|
|
116
99
|
return hookFn.apply(this, args);
|
|
117
100
|
};
|
|
118
|
-
testRunHookDefinition.code = (
|
|
101
|
+
testRunHookDefinition.code = (isFunctionAsync(hookFn)) ? userHookAsyncFn : userHookFn;
|
|
119
102
|
}
|
|
120
103
|
});
|
|
121
104
|
});
|
|
122
105
|
}
|
|
123
|
-
exports.setUserHookNames = setUserHookNames;
|
|
124
106
|
/**
|
|
125
107
|
* Returns true/false if testCase should be kept for current capabilities
|
|
126
108
|
* according to tag in the syntax @skip([conditions])
|
|
127
109
|
* For example "@skip(browserName=firefox)" or "@skip(browserName=chrome,platform=/.+n?x/)"
|
|
128
110
|
* @param {*} testCase
|
|
129
111
|
*/
|
|
130
|
-
function filterPickles(capabilities, pickle) {
|
|
112
|
+
export function filterPickles(capabilities, pickle) {
|
|
131
113
|
const skipTag = /^@skip\((.*)\)$/;
|
|
132
114
|
const match = (value, expr) => {
|
|
133
115
|
if (Array.isArray(expr)) {
|
|
@@ -151,37 +133,33 @@ function filterPickles(capabilities, pickle) {
|
|
|
151
133
|
return acc;
|
|
152
134
|
}, {});
|
|
153
135
|
return !(pickle && pickle.tags && pickle.tags
|
|
154
|
-
.map(p =>
|
|
136
|
+
.map(p => p.name?.match(skipTag))
|
|
155
137
|
.filter(Boolean)
|
|
156
138
|
.map(m => parse(m[1]))
|
|
157
139
|
.find((filter) => Object.keys(filter)
|
|
158
140
|
.every((key) => match(capabilities[key], filter[key]))));
|
|
159
141
|
}
|
|
160
|
-
exports.filterPickles = filterPickles;
|
|
161
142
|
/**
|
|
162
143
|
* The reporters need to have the rule.
|
|
163
144
|
* They are NOT available on the scenario, they ARE on the feature.
|
|
164
145
|
* This will add them to it
|
|
165
146
|
*/
|
|
166
|
-
function getRule(feature, scenarioId) {
|
|
167
|
-
|
|
168
|
-
const rules = (_a = feature.children) === null || _a === void 0 ? void 0 : _a.filter((child) => Object.keys(child)[0] === 'rule');
|
|
147
|
+
export function getRule(feature, scenarioId) {
|
|
148
|
+
const rules = feature.children?.filter((child) => Object.keys(child)[0] === 'rule');
|
|
169
149
|
const rule = rules.find((rule) => {
|
|
170
|
-
|
|
171
|
-
let scenarioRule = (_b = (_a = rule.rule) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.find((child) => { var _a; return ((_a = child.scenario) === null || _a === void 0 ? void 0 : _a.id) === scenarioId; });
|
|
150
|
+
let scenarioRule = rule.rule?.children?.find((child) => child.scenario?.id === scenarioId);
|
|
172
151
|
if (scenarioRule) {
|
|
173
152
|
return rule;
|
|
174
153
|
}
|
|
175
154
|
});
|
|
176
|
-
return
|
|
155
|
+
return rule?.rule?.name;
|
|
177
156
|
}
|
|
178
|
-
exports.getRule = getRule;
|
|
179
157
|
/**
|
|
180
158
|
* The reporters need to have the keywords, like `Given|When|Then`. They are NOT available
|
|
181
159
|
* on the scenario, they ARE on the feature.
|
|
182
160
|
* This will aad them
|
|
183
161
|
*/
|
|
184
|
-
function addKeywordToStep(steps, feature) {
|
|
162
|
+
export function addKeywordToStep(steps, feature) {
|
|
185
163
|
return steps.map(step => {
|
|
186
164
|
// Steps without a astNodeIds are hooks
|
|
187
165
|
if (step.astNodeIds && step.astNodeIds.length > 0 && feature.children) {
|
|
@@ -192,7 +170,7 @@ function addKeywordToStep(steps, feature) {
|
|
|
192
170
|
const astNodeId = step.astNodeIds[0];
|
|
193
171
|
const rules = feature.children.filter((child) => Object.keys(child)[0] === 'rule');
|
|
194
172
|
let featureChildren = feature.children.filter((child) => Object.keys(child)[0] !== 'rule');
|
|
195
|
-
const rulesChildrens = rules.map((child) =>
|
|
173
|
+
const rulesChildrens = rules.map((child) => child.rule?.children).flat();
|
|
196
174
|
featureChildren = featureChildren.concat(rulesChildrens);
|
|
197
175
|
featureChildren.find((child) =>
|
|
198
176
|
// @ts-ignore
|
|
@@ -207,4 +185,3 @@ function addKeywordToStep(steps, feature) {
|
|
|
207
185
|
return step;
|
|
208
186
|
});
|
|
209
187
|
}
|
|
210
|
-
exports.addKeywordToStep = addKeywordToStep;
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/cucumber-framework",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.8-alpha.219+4aab2cef1",
|
|
4
4
|
"description": "A WebdriverIO plugin. Adapter for Cucumber.js testing framework.",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-cucumber-framework",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "./build/index",
|
|
9
8
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
9
|
+
"node": "^16.13 || >=18"
|
|
11
10
|
},
|
|
12
11
|
"repository": {
|
|
13
12
|
"type": "git",
|
|
@@ -21,29 +20,31 @@
|
|
|
21
20
|
"bugs": {
|
|
22
21
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
23
22
|
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": "./build/index.js",
|
|
25
|
+
"types": "./build/index.d.ts",
|
|
26
|
+
"typeScriptVersion": "3.8.3",
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"@cucumber/cucumber": "8.
|
|
28
|
+
"@cucumber/cucumber": "8.5.1",
|
|
26
29
|
"@cucumber/gherkin": "24.0.0",
|
|
27
30
|
"@cucumber/gherkin-streams": "^5.0.0",
|
|
28
|
-
"@cucumber/messages": "19.
|
|
31
|
+
"@cucumber/messages": "19.1.2",
|
|
29
32
|
"@types/is-glob": "^4.0.1",
|
|
30
33
|
"@types/long": "^4.0.1",
|
|
31
34
|
"@types/mockery": "^1.4.29",
|
|
32
35
|
"@wdio/logger": "7.19.0",
|
|
33
|
-
"@wdio/types": "7.20.
|
|
34
|
-
"@wdio/utils": "7.20.
|
|
35
|
-
"expect-webdriverio": "^3.0.0",
|
|
36
|
+
"@wdio/types": "7.20.7",
|
|
37
|
+
"@wdio/utils": "7.20.7",
|
|
36
38
|
"glob": "^8.0.3",
|
|
37
39
|
"is-glob": "^4.0.0",
|
|
38
40
|
"long": "^4.0.0",
|
|
39
41
|
"mockery": "^2.1.0"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@wdio/cli": "
|
|
44
|
+
"@wdio/cli": "next"
|
|
43
45
|
},
|
|
44
46
|
"publishConfig": {
|
|
45
47
|
"access": "public"
|
|
46
48
|
},
|
|
47
|
-
"
|
|
48
|
-
"gitHead": "df5cbf4f557ddc04f49ebc25b9a74231fdd44f2b"
|
|
49
|
+
"gitHead": "4aab2cef1b8b195ac8cc611f28b1fd54e4ba3443"
|
|
49
50
|
}
|