@wdio/cucumber-framework 7.20.8-alpha.219 → 7.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/constants.d.ts +2 -2
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +9 -5
- package/build/cucumberEventListener.d.ts +2 -2
- package/build/cucumberEventListener.d.ts.map +1 -1
- package/build/cucumberEventListener.js +42 -34
- package/build/index.d.ts +11 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +114 -65
- package/build/reporter.d.ts +5 -4
- package/build/reporter.d.ts.map +1 -1
- package/build/reporter.js +46 -36
- package/build/types.js +2 -1
- package/build/utils.d.ts +2 -2
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +49 -26
- package/package.json +9 -10
package/build/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CucumberOptions } from './types';
|
|
2
|
+
import { 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,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEvD,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,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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 = {
|
|
3
6
|
backtrace: false,
|
|
4
7
|
requireModule: [],
|
|
5
8
|
failAmbiguousDefinitions: false,
|
|
@@ -13,14 +16,15 @@ export const DEFAULT_OPTS = {
|
|
|
13
16
|
strict: false,
|
|
14
17
|
tagExpression: '',
|
|
15
18
|
tagsInTitle: false,
|
|
16
|
-
timeout: DEFAULT_TIMEOUT,
|
|
19
|
+
timeout: exports.DEFAULT_TIMEOUT,
|
|
17
20
|
retry: 0,
|
|
18
21
|
scenarioLevelReporter: false,
|
|
19
22
|
featureDefaultLanguage: 'en'
|
|
20
23
|
};
|
|
21
24
|
/* istanbul ignore next */
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
const NOOP = function () { };
|
|
26
|
+
exports.NOOP = NOOP;
|
|
27
|
+
exports.CUCUMBER_HOOK_DEFINITION_TYPES = [
|
|
24
28
|
'beforeTestRunHookDefinitionConfigs',
|
|
25
29
|
'beforeTestCaseHookDefinitionConfigs',
|
|
26
30
|
'afterTestCaseHookDefinitionConfigs',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from '
|
|
2
|
+
import { EventEmitter } from '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
|
|
6
|
+
import { 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,QAAQ,CAAA;AACrC,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;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMpC,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,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const events_1 = require("events");
|
|
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 {
|
|
7
12
|
constructor(eventBroadcaster, _pickleFilter) {
|
|
8
13
|
super();
|
|
9
14
|
this._pickleFilter = _pickleFilter;
|
|
@@ -253,14 +258,14 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
253
258
|
onTestCaseStarted(testcase) {
|
|
254
259
|
this._currentTestCase = testcase;
|
|
255
260
|
const tc = this._testCases.find(tc => tc.id === testcase.testCaseId);
|
|
256
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc
|
|
261
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc === null || tc === void 0 ? void 0 : tc.pickleId));
|
|
257
262
|
/* istanbul ignore if */
|
|
258
263
|
if (!scenario) {
|
|
259
264
|
return;
|
|
260
265
|
}
|
|
261
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario
|
|
262
|
-
const uri = doc
|
|
263
|
-
const feature = doc
|
|
266
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === (scenario === null || scenario === void 0 ? void 0 : scenario.uri));
|
|
267
|
+
const uri = doc === null || doc === void 0 ? void 0 : doc.uri;
|
|
268
|
+
const feature = doc === null || doc === void 0 ? void 0 : doc.feature;
|
|
264
269
|
if (this._currentDoc.uri && this._currentDoc.feature && this.usesSpecGrouping() && doc != this._currentDoc && this.featureIsStarted(this._currentDoc.uri)) {
|
|
265
270
|
this.emit('after-feature', this._currentDoc.uri, this._currentDoc.feature);
|
|
266
271
|
}
|
|
@@ -275,12 +280,12 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
275
280
|
* This will aad them
|
|
276
281
|
*/
|
|
277
282
|
if (scenario.steps && feature) {
|
|
278
|
-
scenario.steps = addKeywordToStep(scenario.steps, feature);
|
|
283
|
+
scenario.steps = (0, utils_1.addKeywordToStep)(scenario.steps, feature);
|
|
279
284
|
}
|
|
280
285
|
this._currentPickle = { uri, feature, scenario };
|
|
281
286
|
let reporterScenario = scenario;
|
|
282
|
-
reporterScenario.rule = getRule(doc
|
|
283
|
-
this.emit('before-scenario', scenario.uri, doc
|
|
287
|
+
reporterScenario.rule = (0, utils_1.getRule)(doc === null || doc === void 0 ? void 0 : doc.feature, this._pickleMap.get(scenario.id));
|
|
288
|
+
this.emit('before-scenario', scenario.uri, doc === null || doc === void 0 ? void 0 : doc.feature, reporterScenario);
|
|
284
289
|
}
|
|
285
290
|
// {
|
|
286
291
|
// "testStepStarted": {
|
|
@@ -293,13 +298,14 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
293
298
|
// }
|
|
294
299
|
// }
|
|
295
300
|
onTestStepStarted(testStepStartedEvent) {
|
|
301
|
+
var _a, _b;
|
|
296
302
|
const testcase = this._testCases.find((testcase) => this._currentTestCase && testcase.id === this._currentTestCase.testCaseId);
|
|
297
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase
|
|
298
|
-
const teststep = testcase
|
|
299
|
-
const step = scenario
|
|
300
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario
|
|
301
|
-
const uri = doc
|
|
302
|
-
const feature = doc
|
|
303
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase === null || testcase === void 0 ? void 0 : testcase.pickleId));
|
|
304
|
+
const teststep = (_a = testcase === null || testcase === void 0 ? void 0 : testcase.testSteps) === null || _a === void 0 ? void 0 : _a.find((step) => step.id === testStepStartedEvent.testStepId);
|
|
305
|
+
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;
|
|
306
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === (scenario === null || scenario === void 0 ? void 0 : scenario.uri));
|
|
307
|
+
const uri = doc === null || doc === void 0 ? void 0 : doc.uri;
|
|
308
|
+
const feature = doc === null || doc === void 0 ? void 0 : doc.feature;
|
|
303
309
|
/* istanbul ignore if */
|
|
304
310
|
if (!step) {
|
|
305
311
|
return;
|
|
@@ -325,14 +331,15 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
325
331
|
// }
|
|
326
332
|
// }
|
|
327
333
|
onTestStepFinished(testStepFinishedEvent) {
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
const
|
|
331
|
-
const
|
|
334
|
+
var _a, _b;
|
|
335
|
+
const testcase = this._testCases.find((testcase) => { var _a; return testcase.id === ((_a = this._currentTestCase) === null || _a === void 0 ? void 0 : _a.testCaseId); });
|
|
336
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(testcase === null || testcase === void 0 ? void 0 : testcase.pickleId));
|
|
337
|
+
const teststep = (_a = testcase === null || testcase === void 0 ? void 0 : testcase.testSteps) === null || _a === void 0 ? void 0 : _a.find((step) => step.id === testStepFinishedEvent.testStepId);
|
|
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;
|
|
332
339
|
const result = testStepFinishedEvent.testStepResult;
|
|
333
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario
|
|
334
|
-
const uri = doc
|
|
335
|
-
const feature = doc
|
|
340
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === (scenario === null || scenario === void 0 ? void 0 : scenario.uri));
|
|
341
|
+
const uri = doc === null || doc === void 0 ? void 0 : doc.uri;
|
|
342
|
+
const feature = doc === null || doc === void 0 ? void 0 : doc.feature;
|
|
336
343
|
/* istanbul ignore if */
|
|
337
344
|
if (!step) {
|
|
338
345
|
return;
|
|
@@ -350,8 +357,8 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
350
357
|
// }
|
|
351
358
|
// }
|
|
352
359
|
onTestCaseFinished(results) {
|
|
353
|
-
const tc = this._testCases.find(tc => tc.id === this._currentTestCase
|
|
354
|
-
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc
|
|
360
|
+
const tc = this._testCases.find(tc => { var _a; return tc.id === ((_a = this._currentTestCase) === null || _a === void 0 ? void 0 : _a.testCaseId); });
|
|
361
|
+
const scenario = this._scenarios.find(sc => sc.id === this._suiteMap.get(tc === null || tc === void 0 ? void 0 : tc.pickleId));
|
|
355
362
|
/* istanbul ignore if */
|
|
356
363
|
if (!scenario) {
|
|
357
364
|
return;
|
|
@@ -359,12 +366,12 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
359
366
|
/**
|
|
360
367
|
* propagate the first non passing result or the last one
|
|
361
368
|
*/
|
|
362
|
-
const finalResult = results.find((r) => r.status !== Status.PASSED) || results.pop();
|
|
363
|
-
const doc = this._gherkinDocEvents.find(gde => gde.uri === scenario
|
|
364
|
-
const uri = doc
|
|
365
|
-
const feature = doc
|
|
369
|
+
const finalResult = results.find((r) => r.status !== cucumber_1.Status.PASSED) || results.pop();
|
|
370
|
+
const doc = this._gherkinDocEvents.find(gde => gde.uri === (scenario === null || scenario === void 0 ? void 0 : scenario.uri));
|
|
371
|
+
const uri = doc === null || doc === void 0 ? void 0 : doc.uri;
|
|
372
|
+
const feature = doc === null || doc === void 0 ? void 0 : doc.feature;
|
|
366
373
|
this._currentPickle = { uri, feature, scenario };
|
|
367
|
-
this.emit('after-scenario', doc
|
|
374
|
+
this.emit('after-scenario', doc === null || doc === void 0 ? void 0 : doc.uri, doc === null || doc === void 0 ? void 0 : doc.feature, scenario, finalResult);
|
|
368
375
|
}
|
|
369
376
|
// testRunFinishedEvent = {
|
|
370
377
|
// "timestamp": {
|
|
@@ -398,7 +405,7 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
398
405
|
/**
|
|
399
406
|
* match based on capability tags
|
|
400
407
|
*/
|
|
401
|
-
.filter(([, fakeId]) => filterPickles(caps, this._scenarios.find(s => s.id === fakeId)))
|
|
408
|
+
.filter(([, fakeId]) => (0, utils_1.filterPickles)(caps, this._scenarios.find(s => s.id === fakeId)))
|
|
402
409
|
/**
|
|
403
410
|
* match based on Cucumber pickle filter
|
|
404
411
|
*/
|
|
@@ -409,3 +416,4 @@ export default class CucumberEventListener extends EventEmitter {
|
|
|
409
416
|
.map(([id]) => id);
|
|
410
417
|
}
|
|
411
418
|
}
|
|
419
|
+
exports.default = CucumberEventListener;
|
package/build/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="expect-webdriverio/types/standalone" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
3
4
|
import * as Cucumber from '@cucumber/cucumber';
|
|
4
5
|
import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
|
|
5
6
|
import { Long } from 'long';
|
|
6
7
|
import type { Capabilities, Options } from '@wdio/types';
|
|
7
|
-
import type
|
|
8
|
+
import type ExpectWebdriverIO from 'expect-webdriverio';
|
|
9
|
+
import { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types';
|
|
8
10
|
declare class CucumberAdapter {
|
|
9
11
|
private _cid;
|
|
10
12
|
private _config;
|
|
@@ -39,9 +41,9 @@ declare class CucumberAdapter {
|
|
|
39
41
|
* Or pass your own function
|
|
40
42
|
* Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
|
|
41
43
|
*/
|
|
42
|
-
registerRequiredModules():
|
|
44
|
+
registerRequiredModules(): void;
|
|
43
45
|
requiredFiles(): string[];
|
|
44
|
-
loadSpecFiles():
|
|
46
|
+
loadSpecFiles(): void;
|
|
45
47
|
/**
|
|
46
48
|
* set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
|
|
47
49
|
* @param {object} config config
|
|
@@ -76,5 +78,10 @@ declare global {
|
|
|
76
78
|
interface HookFunctionExtension extends HookFunctionExtensionImport {
|
|
77
79
|
}
|
|
78
80
|
}
|
|
81
|
+
namespace NodeJS {
|
|
82
|
+
interface Global {
|
|
83
|
+
expect: ExpectWebdriverIO.Expect;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
79
86
|
}
|
|
80
87
|
//# 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":";;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAMrC,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;AAK3B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAI3B,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAc,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,iBAAiB,MAAM,oBAAoB,CAAA;AAIvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,qBAAqB,IAAI,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAatH,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,CAAoB;IAC/C,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;IA0B7B,IAAI;IAmCV,QAAQ;IAIF,GAAG;IAkET;;;;;;;;OAQG;IACH,uBAAuB;IAYvB,aAAa;IAUb,aAAa;IAsBb;;;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;IACD,UAAU,MAAM,CAAC;QACb,UAAU,MAAM;YACZ,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAA;SACnC;KACJ;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -1,26 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
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;
|
|
19
61
|
function getResultObject(world) {
|
|
62
|
+
var _a, _b, _c, _d, _e;
|
|
20
63
|
return {
|
|
21
|
-
passed: (world.result
|
|
22
|
-
error: world.result
|
|
23
|
-
duration: world.result
|
|
64
|
+
passed: (((_a = world.result) === null || _a === void 0 ? void 0 : _a.status) === Cucumber.Status.PASSED || ((_b = world.result) === null || _b === void 0 ? void 0 : _b.status) === Cucumber.Status.SKIPPED),
|
|
65
|
+
error: (_c = world.result) === null || _c === void 0 ? void 0 : _c.message,
|
|
66
|
+
duration: ((_e = (_d = world.result) === null || _d === void 0 ? void 0 : _d.duration) === null || _e === void 0 ? void 0 : _e.nanos) / 1e6 // convert into ms
|
|
24
67
|
};
|
|
25
68
|
}
|
|
26
69
|
class CucumberAdapter {
|
|
@@ -32,17 +75,12 @@ class CucumberAdapter {
|
|
|
32
75
|
this._reporter = _reporter;
|
|
33
76
|
this._cwd = process.cwd();
|
|
34
77
|
this._newId = incrementing();
|
|
35
|
-
this._cucumberOpts = Object.assign({}, DEFAULT_OPTS, this._config.cucumberOpts);
|
|
78
|
+
this._cucumberOpts = Object.assign({}, constants_1.DEFAULT_OPTS, this._config.cucumberOpts);
|
|
36
79
|
this._hasTests = true;
|
|
37
80
|
this._cucumberFeaturesWithLineNumbers = this._config.cucumberFeaturesWithLineNumbers || [];
|
|
38
|
-
this._eventBroadcaster = new EventEmitter();
|
|
39
|
-
this._eventDataCollector = new
|
|
40
|
-
|
|
41
|
-
? spec.slice(FILE_PROTOCOL.length)
|
|
42
|
-
: spec));
|
|
43
|
-
const featurePathsToRun = this._cucumberFeaturesWithLineNumbers.length > 0
|
|
44
|
-
? this._cucumberFeaturesWithLineNumbers
|
|
45
|
-
: this._specs;
|
|
81
|
+
this._eventBroadcaster = new events_1.EventEmitter();
|
|
82
|
+
this._eventDataCollector = new event_data_collector_1.default(this._eventBroadcaster);
|
|
83
|
+
const featurePathsToRun = this._cucumberFeaturesWithLineNumbers.length > 0 ? this._cucumberFeaturesWithLineNumbers : this._specs;
|
|
46
84
|
this._pickleFilter = new Cucumber.PickleFilter({
|
|
47
85
|
cwd: this._cwd,
|
|
48
86
|
featurePaths: featurePathsToRun,
|
|
@@ -56,11 +94,11 @@ class CucumberAdapter {
|
|
|
56
94
|
tagsInTitle: Boolean(this._cucumberOpts.tagsInTitle),
|
|
57
95
|
scenarioLevelReporter: Boolean(this._cucumberOpts.scenarioLevelReporter)
|
|
58
96
|
};
|
|
59
|
-
this._cucumberReporter = new
|
|
97
|
+
this._cucumberReporter = new reporter_1.default(this._eventBroadcaster, this._pickleFilter, reporterOptions, this._cid, this._specs, this._reporter);
|
|
60
98
|
}
|
|
61
99
|
async init() {
|
|
62
100
|
try {
|
|
63
|
-
const gherkinMessageStream = GherkinStreams.fromPaths(this._specs, {
|
|
101
|
+
const gherkinMessageStream = gherkin_streams_1.GherkinStreams.fromPaths(this._specs, {
|
|
64
102
|
defaultDialect: this._cucumberOpts.featureDefaultLanguage,
|
|
65
103
|
newId: this._newId
|
|
66
104
|
});
|
|
@@ -75,9 +113,18 @@ class CucumberAdapter {
|
|
|
75
113
|
this._hasTests = this._cucumberReporter.eventListener.getPickleIds(this._capabilities).length > 0;
|
|
76
114
|
}
|
|
77
115
|
catch (runtimeError) {
|
|
78
|
-
await executeHooksWithArgs('after', this._config.after, [runtimeError, this._capabilities, this._specs]);
|
|
116
|
+
await (0, utils_1.executeHooksWithArgs)('after', this._config.after, [runtimeError, this._capabilities, this._specs]);
|
|
79
117
|
throw runtimeError;
|
|
80
118
|
}
|
|
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
|
+
});
|
|
81
128
|
return this;
|
|
82
129
|
}
|
|
83
130
|
hasTests() {
|
|
@@ -87,19 +134,19 @@ class CucumberAdapter {
|
|
|
87
134
|
let runtimeError;
|
|
88
135
|
let result;
|
|
89
136
|
try {
|
|
90
|
-
|
|
137
|
+
this.registerRequiredModules();
|
|
91
138
|
Cucumber.supportCodeLibraryBuilder.reset(this._cwd, this._newId);
|
|
92
139
|
/**
|
|
93
140
|
* wdio hooks should be added before spec files are loaded
|
|
94
141
|
*/
|
|
95
142
|
this.addWdioHooks(this._config);
|
|
96
|
-
|
|
143
|
+
this.loadSpecFiles();
|
|
97
144
|
this.wrapSteps(this._config);
|
|
98
145
|
/**
|
|
99
146
|
* we need to somehow identify is function is step or hook
|
|
100
147
|
* so we wrap every user hook function
|
|
101
148
|
*/
|
|
102
|
-
setUserHookNames(Cucumber.supportCodeLibraryBuilder);
|
|
149
|
+
(0, utils_2.setUserHookNames)(Cucumber.supportCodeLibraryBuilder);
|
|
103
150
|
Cucumber.setDefaultTimeout(this._cucumberOpts.timeout);
|
|
104
151
|
const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize();
|
|
105
152
|
/**
|
|
@@ -131,7 +178,7 @@ class CucumberAdapter {
|
|
|
131
178
|
runtimeError = err;
|
|
132
179
|
result = 1;
|
|
133
180
|
}
|
|
134
|
-
await executeHooksWithArgs('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
|
|
181
|
+
await (0, utils_1.executeHooksWithArgs)('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
|
|
135
182
|
/**
|
|
136
183
|
* in case the spec has a runtime error throw after the wdio hook
|
|
137
184
|
*/
|
|
@@ -150,70 +197,71 @@ class CucumberAdapter {
|
|
|
150
197
|
* Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
|
|
151
198
|
*/
|
|
152
199
|
registerRequiredModules() {
|
|
153
|
-
|
|
200
|
+
this._cucumberOpts.requireModule.map(requiredModule => {
|
|
154
201
|
if (Array.isArray(requiredModule)) {
|
|
155
|
-
(
|
|
202
|
+
require(requiredModule[0])(requiredModule[1]);
|
|
156
203
|
}
|
|
157
204
|
else if (typeof requiredModule === 'function') {
|
|
158
205
|
requiredModule();
|
|
159
206
|
}
|
|
160
207
|
else {
|
|
161
|
-
|
|
208
|
+
require(requiredModule);
|
|
162
209
|
}
|
|
163
210
|
});
|
|
164
211
|
}
|
|
165
212
|
requiredFiles() {
|
|
166
|
-
return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat(
|
|
167
|
-
?
|
|
213
|
+
return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat((0, is_glob_1.default)(requiredFile)
|
|
214
|
+
? glob_1.default.sync(requiredFile)
|
|
168
215
|
: [requiredFile]), []);
|
|
169
216
|
}
|
|
170
|
-
|
|
217
|
+
loadSpecFiles() {
|
|
171
218
|
// we use mockery to allow people to import 'our' cucumber even though their spec files are in their folders
|
|
172
219
|
// because of that we don't have to attach anything to the global object, and the current cucumber spec files
|
|
173
220
|
// should just work with no changes with this framework
|
|
174
|
-
|
|
221
|
+
mockery_1.default.enable({
|
|
175
222
|
useCleanCache: false,
|
|
176
223
|
warnOnReplace: false,
|
|
177
224
|
warnOnUnregistered: false
|
|
178
225
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const filepath =
|
|
226
|
+
mockery_1.default.registerMock('@cucumber/cucumber', Cucumber);
|
|
227
|
+
this.requiredFiles().forEach((codePath) => {
|
|
228
|
+
const filepath = path_1.default.isAbsolute(codePath)
|
|
182
229
|
? codePath
|
|
183
|
-
:
|
|
230
|
+
: path_1.default.join(process.cwd(), codePath);
|
|
184
231
|
// This allows rerunning a stepDefinitions file
|
|
185
232
|
delete require.cache[require.resolve(filepath)];
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
|
|
233
|
+
require(filepath);
|
|
234
|
+
});
|
|
235
|
+
mockery_1.default.disable();
|
|
189
236
|
}
|
|
190
237
|
/**
|
|
191
238
|
* set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
|
|
192
239
|
* @param {object} config config
|
|
193
240
|
*/
|
|
194
241
|
addWdioHooks(config) {
|
|
195
|
-
|
|
242
|
+
var _a;
|
|
243
|
+
const eventListener = (_a = this._cucumberReporter) === null || _a === void 0 ? void 0 : _a.eventListener;
|
|
196
244
|
Cucumber.BeforeAll(async function wdioHookBeforeFeature() {
|
|
197
|
-
const params = eventListener
|
|
198
|
-
await executeHooksWithArgs('beforeFeature', config.beforeFeature, [params
|
|
245
|
+
const params = eventListener === null || eventListener === void 0 ? void 0 : eventListener.getHookParams();
|
|
246
|
+
await (0, utils_1.executeHooksWithArgs)('beforeFeature', config.beforeFeature, [params === null || params === void 0 ? void 0 : params.uri, params === null || params === void 0 ? void 0 : params.feature]);
|
|
199
247
|
});
|
|
200
248
|
Cucumber.AfterAll(async function wdioHookAfterFeature() {
|
|
201
|
-
const params = eventListener
|
|
202
|
-
await executeHooksWithArgs('afterFeature', config.afterFeature, [params
|
|
249
|
+
const params = eventListener === null || eventListener === void 0 ? void 0 : eventListener.getHookParams();
|
|
250
|
+
await (0, utils_1.executeHooksWithArgs)('afterFeature', config.afterFeature, [params === null || params === void 0 ? void 0 : params.uri, params === null || params === void 0 ? void 0 : params.feature]);
|
|
203
251
|
});
|
|
204
252
|
Cucumber.Before(async function wdioHookBeforeScenario(world) {
|
|
205
|
-
await executeHooksWithArgs('beforeScenario', config.beforeScenario, [world, this]);
|
|
253
|
+
await (0, utils_1.executeHooksWithArgs)('beforeScenario', config.beforeScenario, [world, this]);
|
|
206
254
|
});
|
|
207
255
|
Cucumber.After(async function wdioHookAfterScenario(world) {
|
|
208
|
-
await executeHooksWithArgs('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
|
|
256
|
+
await (0, utils_1.executeHooksWithArgs)('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
|
|
209
257
|
});
|
|
210
258
|
Cucumber.BeforeStep(async function wdioHookBeforeStep() {
|
|
211
|
-
const params = eventListener
|
|
212
|
-
await executeHooksWithArgs('beforeStep', config.beforeStep, [params
|
|
259
|
+
const params = eventListener === null || eventListener === void 0 ? void 0 : eventListener.getHookParams();
|
|
260
|
+
await (0, utils_1.executeHooksWithArgs)('beforeStep', config.beforeStep, [params === null || params === void 0 ? void 0 : params.step, params === null || params === void 0 ? void 0 : params.scenario, this]);
|
|
213
261
|
});
|
|
214
262
|
Cucumber.AfterStep(async function wdioHookAfterStep(world) {
|
|
215
|
-
const params = eventListener
|
|
216
|
-
await executeHooksWithArgs('afterStep', config.afterStep, [params
|
|
263
|
+
const params = eventListener === null || eventListener === void 0 ? void 0 : eventListener.getHookParams();
|
|
264
|
+
await (0, utils_1.executeHooksWithArgs)('afterStep', config.afterStep, [params === null || params === void 0 ? void 0 : params.step, params === null || params === void 0 ? void 0 : params.scenario, getResultObject(world), this]);
|
|
217
265
|
});
|
|
218
266
|
}
|
|
219
267
|
/**
|
|
@@ -259,12 +307,14 @@ class CucumberAdapter {
|
|
|
259
307
|
*/
|
|
260
308
|
const beforeFn = config.beforeHook;
|
|
261
309
|
const afterFn = config.afterHook;
|
|
262
|
-
return testFnWrapper.call(this, isStep ? 'Step' : 'Hook', { specFn: code, specFnArgs: args }, { beforeFn: beforeFn, beforeFnArgs: (context) => [hookParams
|
|
310
|
+
return utils_1.testFnWrapper.call(this, isStep ? 'Step' : 'Hook', { specFn: code, specFnArgs: args }, { beforeFn: beforeFn, beforeFnArgs: (context) => [hookParams === null || hookParams === void 0 ? void 0 : hookParams.step, context] }, { afterFn: afterFn, afterFnArgs: (context) => [hookParams === null || hookParams === void 0 ? void 0 : hookParams.step, context] }, cid, retryTest);
|
|
263
311
|
};
|
|
264
312
|
}
|
|
265
313
|
}
|
|
314
|
+
exports.CucumberAdapter = CucumberAdapter;
|
|
266
315
|
const _CucumberAdapter = CucumberAdapter;
|
|
267
316
|
const adapterFactory = {};
|
|
317
|
+
exports.adapterFactory = adapterFactory;
|
|
268
318
|
/**
|
|
269
319
|
* tested by smoke tests
|
|
270
320
|
*/
|
|
@@ -275,5 +325,4 @@ adapterFactory.init = async function (...args) {
|
|
|
275
325
|
const instance = await adapter.init();
|
|
276
326
|
return instance;
|
|
277
327
|
};
|
|
278
|
-
|
|
279
|
-
export { CucumberAdapter, adapterFactory, After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, Then, When, World };
|
|
328
|
+
exports.default = adapterFactory;
|
package/build/reporter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from '
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
3
|
import { PickleFilter } from '@cucumber/cucumber';
|
|
4
4
|
import { Feature, Pickle, PickleStep, TestStep, TestStepResult } from '@cucumber/messages';
|
|
5
|
-
import CucumberEventListener from './cucumberEventListener
|
|
6
|
-
import { ReporterScenario } from './constants.js';
|
|
5
|
+
import CucumberEventListener from './cucumberEventListener';
|
|
7
6
|
import type { ReporterOptions } from './types';
|
|
8
|
-
|
|
7
|
+
import { ReporterScenario } from './constants';
|
|
8
|
+
declare class CucumberReporter {
|
|
9
9
|
private _options;
|
|
10
10
|
private _cid;
|
|
11
11
|
private _specs;
|
|
@@ -29,4 +29,5 @@ export default class CucumberReporter {
|
|
|
29
29
|
emit(event: string, payload: any): void;
|
|
30
30
|
getTitle(featureOrScenario: Feature | Pickle): string;
|
|
31
31
|
}
|
|
32
|
+
export default CucumberReporter;
|
|
32
33
|
//# 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,QAAQ,CAAA;AACrC,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,yBAAyB,CAAA;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,cAAM,gBAAgB;IAad,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;AAED,eAAe,gBAAgB,CAAA"}
|
package/build/reporter.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
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 {
|
|
5
10
|
constructor(eventBroadcaster, pickleFilter, _options, _cid, _specs, _reporter) {
|
|
6
11
|
this._options = _options;
|
|
7
12
|
this._cid = _cid;
|
|
@@ -10,7 +15,7 @@ export default class CucumberReporter {
|
|
|
10
15
|
this.failedCount = 0;
|
|
11
16
|
this._tagsInTitle = this._options.tagsInTitle || false;
|
|
12
17
|
this._scenarioLevelReport = this._options.scenarioLevelReporter;
|
|
13
|
-
this.eventListener = new
|
|
18
|
+
this.eventListener = new cucumberEventListener_1.default(eventBroadcaster, pickleFilter)
|
|
14
19
|
.on('before-feature', this.handleBeforeFeature.bind(this))
|
|
15
20
|
.on('before-scenario', this.handleBeforeScenario.bind(this))
|
|
16
21
|
.on('after-scenario', this.handleAfterScenario.bind(this))
|
|
@@ -24,7 +29,7 @@ export default class CucumberReporter {
|
|
|
24
29
|
handleBeforeFeature(uri, feature) {
|
|
25
30
|
this._featureStart = new Date();
|
|
26
31
|
this.emit('suite:start', {
|
|
27
|
-
uid: getFeatureId(uri, feature),
|
|
32
|
+
uid: (0, utils_1.getFeatureId)(uri, feature),
|
|
28
33
|
title: this.getTitle(feature),
|
|
29
34
|
type: 'feature',
|
|
30
35
|
file: uri,
|
|
@@ -39,7 +44,7 @@ export default class CucumberReporter {
|
|
|
39
44
|
this.emit(this._scenarioLevelReport ? 'test:start' : 'suite:start', {
|
|
40
45
|
uid: scenario.id,
|
|
41
46
|
title: this.getTitle(scenario),
|
|
42
|
-
parent: getFeatureId(uri, feature),
|
|
47
|
+
parent: (0, utils_1.getFeatureId)(uri, feature),
|
|
43
48
|
type: 'scenario',
|
|
44
49
|
file: uri,
|
|
45
50
|
tags: scenario.tags,
|
|
@@ -48,56 +53,58 @@ export default class CucumberReporter {
|
|
|
48
53
|
}
|
|
49
54
|
handleBeforeStep(uri, feature, scenario, step) {
|
|
50
55
|
this._testStart = new Date();
|
|
51
|
-
const type = getStepType(step);
|
|
52
|
-
const payload = buildStepPayload(uri, feature, scenario, step, { type });
|
|
56
|
+
const type = (0, utils_1.getStepType)(step);
|
|
57
|
+
const payload = (0, utils_1.buildStepPayload)(uri, feature, scenario, step, { type });
|
|
53
58
|
this.emit(`${type}:start`, payload);
|
|
54
59
|
}
|
|
55
60
|
handleAfterStep(uri, feature, scenario, step, result) {
|
|
56
|
-
const type = getStepType(step);
|
|
61
|
+
const type = (0, utils_1.getStepType)(step);
|
|
57
62
|
if (type === 'hook') {
|
|
58
63
|
return this.afterHook(uri, feature, scenario, step, result);
|
|
59
64
|
}
|
|
60
65
|
return this.afterTest(uri, feature, scenario, step, result);
|
|
61
66
|
}
|
|
62
67
|
afterHook(uri, feature, scenario, step, result) {
|
|
68
|
+
var _a;
|
|
63
69
|
let error;
|
|
64
70
|
if (result.message) {
|
|
65
71
|
error = new Error(result.message.split('\n')[0]);
|
|
66
72
|
error.stack = result.message;
|
|
67
73
|
}
|
|
68
|
-
const payload = buildStepPayload(uri, feature, scenario, step, {
|
|
74
|
+
const payload = (0, utils_1.buildStepPayload)(uri, feature, scenario, step, {
|
|
69
75
|
type: 'hook',
|
|
70
76
|
state: result.status,
|
|
71
77
|
error,
|
|
72
|
-
duration: Date.now() - this._testStart
|
|
78
|
+
duration: Date.now() - ((_a = this._testStart) === null || _a === void 0 ? void 0 : _a.getTime())
|
|
73
79
|
});
|
|
74
80
|
this.emit('hook:end', payload);
|
|
75
81
|
}
|
|
76
82
|
afterTest(uri, feature, scenario, step, result) {
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
77
84
|
let state = 'undefined';
|
|
78
85
|
switch (result.status) {
|
|
79
|
-
case Status.FAILED:
|
|
80
|
-
case Status.UNDEFINED:
|
|
86
|
+
case cucumber_1.Status.FAILED:
|
|
87
|
+
case cucumber_1.Status.UNDEFINED:
|
|
81
88
|
state = 'fail';
|
|
82
89
|
break;
|
|
83
|
-
case Status.PASSED:
|
|
90
|
+
case cucumber_1.Status.PASSED:
|
|
84
91
|
state = 'pass';
|
|
85
92
|
break;
|
|
86
|
-
case Status.PENDING:
|
|
93
|
+
case cucumber_1.Status.PENDING:
|
|
87
94
|
state = 'pending';
|
|
88
95
|
break;
|
|
89
|
-
case Status.SKIPPED:
|
|
96
|
+
case cucumber_1.Status.SKIPPED:
|
|
90
97
|
state = 'skip';
|
|
91
98
|
break;
|
|
92
|
-
case Status.AMBIGUOUS:
|
|
99
|
+
case cucumber_1.Status.AMBIGUOUS:
|
|
93
100
|
state = 'pending';
|
|
94
101
|
break;
|
|
95
102
|
}
|
|
96
103
|
let error = result.message ? new Error(result.message) : undefined;
|
|
97
104
|
let title = step
|
|
98
|
-
? step
|
|
105
|
+
? step === null || step === void 0 ? void 0 : step.text
|
|
99
106
|
: this.getTitle(scenario);
|
|
100
|
-
if (result.status === Status.UNDEFINED) {
|
|
107
|
+
if (result.status === cucumber_1.Status.UNDEFINED) {
|
|
101
108
|
if (this._options.ignoreUndefinedDefinitions) {
|
|
102
109
|
/**
|
|
103
110
|
* mark test as pending
|
|
@@ -113,26 +120,26 @@ export default class CucumberReporter {
|
|
|
113
120
|
const err = new Error((step ? `Step "${title}" is not defined. ` : `Scenario ${title} has undefined steps. `) +
|
|
114
121
|
'You can ignore this error by setting cucumberOpts.ignoreUndefinedDefinitions as true.');
|
|
115
122
|
err.stack = `${err.message}\n\tat Feature(${uri}):1:1\n`;
|
|
116
|
-
const featChildren = feature.children
|
|
123
|
+
const featChildren = (_a = feature.children) === null || _a === void 0 ? void 0 : _a.find(c => { var _a; return scenario.astNodeIds && ((_a = c.scenario) === null || _a === void 0 ? void 0 : _a.id) === scenario.astNodeIds[0]; });
|
|
117
124
|
if (featChildren) {
|
|
118
|
-
err.stack += `\tat Scenario(${featChildren.scenario
|
|
119
|
-
const featStep = featChildren.scenario
|
|
125
|
+
err.stack += `\tat Scenario(${(_b = featChildren.scenario) === null || _b === void 0 ? void 0 : _b.name}):${(_d = (_c = featChildren.scenario) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.line}:${(_f = (_e = featChildren.scenario) === null || _e === void 0 ? void 0 : _e.location) === null || _f === void 0 ? void 0 : _f.column}\n`;
|
|
126
|
+
const featStep = (_h = (_g = featChildren.scenario) === null || _g === void 0 ? void 0 : _g.steps) === null || _h === void 0 ? void 0 : _h.find(s => step.astNodeIds && s.id === step.astNodeIds[0]);
|
|
120
127
|
if (featStep) {
|
|
121
|
-
err.stack += `\tat Step(${featStep.text}):${featStep.location
|
|
128
|
+
err.stack += `\tat Step(${featStep.text}):${(_j = featStep.location) === null || _j === void 0 ? void 0 : _j.line}:${(_k = featStep.location) === null || _k === void 0 ? void 0 : _k.column}\n`;
|
|
122
129
|
}
|
|
123
130
|
}
|
|
124
131
|
error = err;
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
|
-
else if (result.status === Status.FAILED && !result.willBeRetried) {
|
|
128
|
-
error = new Error(result.message
|
|
134
|
+
else if (result.status === cucumber_1.Status.FAILED && !result.willBeRetried) {
|
|
135
|
+
error = new Error((_l = result.message) === null || _l === void 0 ? void 0 : _l.split('\n')[0]);
|
|
129
136
|
error.stack = result.message;
|
|
130
137
|
this.failedCount++;
|
|
131
138
|
}
|
|
132
|
-
else if (result.status === Status.AMBIGUOUS && this._options.failAmbiguousDefinitions) {
|
|
139
|
+
else if (result.status === cucumber_1.Status.AMBIGUOUS && this._options.failAmbiguousDefinitions) {
|
|
133
140
|
state = 'fail';
|
|
134
141
|
this.failedCount++;
|
|
135
|
-
error = new Error(result.message
|
|
142
|
+
error = new Error((_m = result.message) === null || _m === void 0 ? void 0 : _m.split('\n')[0]);
|
|
136
143
|
error.stack = result.message;
|
|
137
144
|
}
|
|
138
145
|
else if (result.willBeRetried) {
|
|
@@ -142,50 +149,52 @@ export default class CucumberReporter {
|
|
|
142
149
|
title: title,
|
|
143
150
|
state,
|
|
144
151
|
error,
|
|
145
|
-
duration: Date.now() - this._testStart
|
|
152
|
+
duration: Date.now() - ((_o = this._testStart) === null || _o === void 0 ? void 0 : _o.getTime()),
|
|
146
153
|
passed: ['pass', 'skip'].includes(state),
|
|
147
154
|
file: uri
|
|
148
155
|
};
|
|
149
156
|
const payload = step
|
|
150
|
-
? buildStepPayload(uri, feature, scenario, step, {
|
|
157
|
+
? (0, utils_1.buildStepPayload)(uri, feature, scenario, step, {
|
|
151
158
|
type: 'step',
|
|
152
159
|
...common
|
|
153
160
|
})
|
|
154
161
|
: {
|
|
155
162
|
type: 'scenario',
|
|
156
163
|
uid: scenario.id,
|
|
157
|
-
parent: getFeatureId(uri, feature),
|
|
164
|
+
parent: (0, utils_1.getFeatureId)(uri, feature),
|
|
158
165
|
tags: scenario.tags,
|
|
159
166
|
...common
|
|
160
167
|
};
|
|
161
168
|
this.emit('test:' + state, payload);
|
|
162
169
|
}
|
|
163
170
|
handleAfterScenario(uri, feature, scenario, result) {
|
|
171
|
+
var _a;
|
|
164
172
|
if (this._scenarioLevelReport) {
|
|
165
173
|
return this.afterTest(uri, feature, scenario, { id: scenario.id }, result);
|
|
166
174
|
}
|
|
167
175
|
this.emit('suite:end', {
|
|
168
176
|
uid: scenario.id,
|
|
169
177
|
title: this.getTitle(scenario),
|
|
170
|
-
parent: getFeatureId(uri, feature),
|
|
178
|
+
parent: (0, utils_1.getFeatureId)(uri, feature),
|
|
171
179
|
type: 'scenario',
|
|
172
180
|
file: uri,
|
|
173
|
-
duration: Date.now() - this._scenarioStart
|
|
181
|
+
duration: Date.now() - ((_a = this._scenarioStart) === null || _a === void 0 ? void 0 : _a.getTime()),
|
|
174
182
|
tags: scenario.tags
|
|
175
183
|
});
|
|
176
184
|
}
|
|
177
185
|
handleAfterFeature(uri, feature) {
|
|
186
|
+
var _a;
|
|
178
187
|
this.emit('suite:end', {
|
|
179
|
-
uid: getFeatureId(uri, feature),
|
|
188
|
+
uid: (0, utils_1.getFeatureId)(uri, feature),
|
|
180
189
|
title: this.getTitle(feature),
|
|
181
190
|
type: 'feature',
|
|
182
191
|
file: uri,
|
|
183
|
-
duration: Date.now() - this._featureStart
|
|
192
|
+
duration: Date.now() - ((_a = this._featureStart) === null || _a === void 0 ? void 0 : _a.getTime()),
|
|
184
193
|
tags: feature.tags
|
|
185
194
|
});
|
|
186
195
|
}
|
|
187
196
|
emit(event, payload) {
|
|
188
|
-
let message = formatMessage({ payload });
|
|
197
|
+
let message = (0, utils_1.formatMessage)({ payload });
|
|
189
198
|
message.cid = this._cid;
|
|
190
199
|
message.specs = this._specs;
|
|
191
200
|
message.uid = payload.uid;
|
|
@@ -199,3 +208,4 @@ export default class CucumberReporter {
|
|
|
199
208
|
return `${tags.map((tag) => tag.name).join(', ')}: ${name}`;
|
|
200
209
|
}
|
|
201
210
|
}
|
|
211
|
+
exports.default = CucumberReporter;
|
package/build/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
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
|
|
4
|
-
import { ReporterStep } from './constants
|
|
3
|
+
import { Capabilities } from '@wdio/types';
|
|
4
|
+
import { ReporterStep } from './constants';
|
|
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,
|
|
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;AAE1C,OAAO,EAAkC,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1E;;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,20 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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');
|
|
6
12
|
/**
|
|
7
13
|
* NOTE: this function is exported for testing only
|
|
8
14
|
*/
|
|
9
|
-
|
|
15
|
+
function createStepArgument({ argument }) {
|
|
16
|
+
var _a;
|
|
10
17
|
if (!argument) {
|
|
11
18
|
return undefined;
|
|
12
19
|
}
|
|
13
20
|
if (argument.dataTable) {
|
|
14
21
|
return {
|
|
15
|
-
rows: argument.dataTable.rows
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
rows: (_a = argument.dataTable.rows) === null || _a === void 0 ? void 0 : _a.map((row) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return ({
|
|
25
|
+
cells: (_a = row.cells) === null || _a === void 0 ? void 0 : _a.map((cell) => cell.value)
|
|
26
|
+
});
|
|
27
|
+
})
|
|
18
28
|
};
|
|
19
29
|
}
|
|
20
30
|
if (argument.docString) {
|
|
@@ -22,11 +32,12 @@ export function createStepArgument({ argument }) {
|
|
|
22
32
|
}
|
|
23
33
|
return undefined;
|
|
24
34
|
}
|
|
35
|
+
exports.createStepArgument = createStepArgument;
|
|
25
36
|
/**
|
|
26
37
|
* format message
|
|
27
38
|
* @param {object} message { type: string, payload: object }
|
|
28
39
|
*/
|
|
29
|
-
|
|
40
|
+
function formatMessage({ payload = {} }) {
|
|
30
41
|
let content = { ...payload };
|
|
31
42
|
/**
|
|
32
43
|
* need to convert Error to plain object, otherwise it is lost on process.send
|
|
@@ -40,6 +51,7 @@ export function formatMessage({ payload = {} }) {
|
|
|
40
51
|
}
|
|
41
52
|
return content;
|
|
42
53
|
}
|
|
54
|
+
exports.formatMessage = formatMessage;
|
|
43
55
|
var StepType;
|
|
44
56
|
(function (StepType) {
|
|
45
57
|
StepType["hook"] = "hook";
|
|
@@ -49,26 +61,30 @@ var StepType;
|
|
|
49
61
|
* Get step type
|
|
50
62
|
* @param {string} type `Step` or `Hook`
|
|
51
63
|
*/
|
|
52
|
-
|
|
64
|
+
function getStepType(step) {
|
|
53
65
|
return step.hookId ? StepType.hook : StepType.test;
|
|
54
66
|
}
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
exports.getStepType = getStepType;
|
|
68
|
+
function getFeatureId(uri, feature) {
|
|
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}`;
|
|
57
71
|
}
|
|
72
|
+
exports.getFeatureId = getFeatureId;
|
|
58
73
|
/**
|
|
59
74
|
* Builds test title from step keyword and text
|
|
60
75
|
* @param {string} keyword
|
|
61
76
|
* @param {string} text
|
|
62
77
|
* @param {string} type
|
|
63
78
|
*/
|
|
64
|
-
|
|
79
|
+
function getTestStepTitle(keyword = '', text = '', type) {
|
|
65
80
|
const title = (!text && type.toLowerCase() !== 'hook') ? 'Undefined Step' : text;
|
|
66
81
|
return `${keyword.trim()} ${title.trim()}`.trim();
|
|
67
82
|
}
|
|
83
|
+
exports.getTestStepTitle = getTestStepTitle;
|
|
68
84
|
/**
|
|
69
85
|
* build payload for test/hook event
|
|
70
86
|
*/
|
|
71
|
-
|
|
87
|
+
function buildStepPayload(uri, feature, scenario, step, params) {
|
|
72
88
|
return {
|
|
73
89
|
...params,
|
|
74
90
|
uid: step.id,
|
|
@@ -82,13 +98,14 @@ export function buildStepPayload(uri, feature, scenario, step, params) {
|
|
|
82
98
|
scenarioName: scenario.name,
|
|
83
99
|
};
|
|
84
100
|
}
|
|
101
|
+
exports.buildStepPayload = buildStepPayload;
|
|
85
102
|
/**
|
|
86
103
|
* wrap every user defined hook with function named `userHookFn`
|
|
87
104
|
* to identify later on is function a step, user hook or wdio hook.
|
|
88
105
|
* @param {object} options `Cucumber.supportCodeLibraryBuilder.options`
|
|
89
106
|
*/
|
|
90
|
-
|
|
91
|
-
CUCUMBER_HOOK_DEFINITION_TYPES.forEach(hookName => {
|
|
107
|
+
function setUserHookNames(options) {
|
|
108
|
+
constants_1.CUCUMBER_HOOK_DEFINITION_TYPES.forEach(hookName => {
|
|
92
109
|
options[hookName].forEach((testRunHookDefinition) => {
|
|
93
110
|
const hookFn = testRunHookDefinition.code;
|
|
94
111
|
if (!hookFn.name.startsWith('wdioHook')) {
|
|
@@ -98,18 +115,19 @@ export function setUserHookNames(options) {
|
|
|
98
115
|
const userHookFn = function (...args) {
|
|
99
116
|
return hookFn.apply(this, args);
|
|
100
117
|
};
|
|
101
|
-
testRunHookDefinition.code = (isFunctionAsync(hookFn)) ? userHookAsyncFn : userHookFn;
|
|
118
|
+
testRunHookDefinition.code = ((0, utils_1.isFunctionAsync)(hookFn)) ? userHookAsyncFn : userHookFn;
|
|
102
119
|
}
|
|
103
120
|
});
|
|
104
121
|
});
|
|
105
122
|
}
|
|
123
|
+
exports.setUserHookNames = setUserHookNames;
|
|
106
124
|
/**
|
|
107
125
|
* Returns true/false if testCase should be kept for current capabilities
|
|
108
126
|
* according to tag in the syntax @skip([conditions])
|
|
109
127
|
* For example "@skip(browserName=firefox)" or "@skip(browserName=chrome,platform=/.+n?x/)"
|
|
110
128
|
* @param {*} testCase
|
|
111
129
|
*/
|
|
112
|
-
|
|
130
|
+
function filterPickles(capabilities, pickle) {
|
|
113
131
|
const skipTag = /^@skip\((.*)\)$/;
|
|
114
132
|
const match = (value, expr) => {
|
|
115
133
|
if (Array.isArray(expr)) {
|
|
@@ -133,33 +151,37 @@ export function filterPickles(capabilities, pickle) {
|
|
|
133
151
|
return acc;
|
|
134
152
|
}, {});
|
|
135
153
|
return !(pickle && pickle.tags && pickle.tags
|
|
136
|
-
.map(p => p.name
|
|
154
|
+
.map(p => { var _a; return (_a = p.name) === null || _a === void 0 ? void 0 : _a.match(skipTag); })
|
|
137
155
|
.filter(Boolean)
|
|
138
156
|
.map(m => parse(m[1]))
|
|
139
157
|
.find((filter) => Object.keys(filter)
|
|
140
158
|
.every((key) => match(capabilities[key], filter[key]))));
|
|
141
159
|
}
|
|
160
|
+
exports.filterPickles = filterPickles;
|
|
142
161
|
/**
|
|
143
162
|
* The reporters need to have the rule.
|
|
144
163
|
* They are NOT available on the scenario, they ARE on the feature.
|
|
145
164
|
* This will add them to it
|
|
146
165
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
function getRule(feature, scenarioId) {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
const rules = (_a = feature.children) === null || _a === void 0 ? void 0 : _a.filter((child) => Object.keys(child)[0] === 'rule');
|
|
149
169
|
const rule = rules.find((rule) => {
|
|
150
|
-
|
|
170
|
+
var _a, _b;
|
|
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; });
|
|
151
172
|
if (scenarioRule) {
|
|
152
173
|
return rule;
|
|
153
174
|
}
|
|
154
175
|
});
|
|
155
|
-
return rule
|
|
176
|
+
return (_b = rule === null || rule === void 0 ? void 0 : rule.rule) === null || _b === void 0 ? void 0 : _b.name;
|
|
156
177
|
}
|
|
178
|
+
exports.getRule = getRule;
|
|
157
179
|
/**
|
|
158
180
|
* The reporters need to have the keywords, like `Given|When|Then`. They are NOT available
|
|
159
181
|
* on the scenario, they ARE on the feature.
|
|
160
182
|
* This will aad them
|
|
161
183
|
*/
|
|
162
|
-
|
|
184
|
+
function addKeywordToStep(steps, feature) {
|
|
163
185
|
return steps.map(step => {
|
|
164
186
|
// Steps without a astNodeIds are hooks
|
|
165
187
|
if (step.astNodeIds && step.astNodeIds.length > 0 && feature.children) {
|
|
@@ -170,7 +192,7 @@ export function addKeywordToStep(steps, feature) {
|
|
|
170
192
|
const astNodeId = step.astNodeIds[0];
|
|
171
193
|
const rules = feature.children.filter((child) => Object.keys(child)[0] === 'rule');
|
|
172
194
|
let featureChildren = feature.children.filter((child) => Object.keys(child)[0] !== 'rule');
|
|
173
|
-
const rulesChildrens = rules.map((child) => child.rule
|
|
195
|
+
const rulesChildrens = rules.map((child) => { var _a; return (_a = child.rule) === null || _a === void 0 ? void 0 : _a.children; }).flat();
|
|
174
196
|
featureChildren = featureChildren.concat(rulesChildrens);
|
|
175
197
|
featureChildren.find((child) =>
|
|
176
198
|
// @ts-ignore
|
|
@@ -185,3 +207,4 @@ export function addKeywordToStep(steps, feature) {
|
|
|
185
207
|
return step;
|
|
186
208
|
});
|
|
187
209
|
}
|
|
210
|
+
exports.addKeywordToStep = addKeywordToStep;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/cucumber-framework",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
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",
|
|
8
9
|
"engines": {
|
|
9
|
-
"node": "
|
|
10
|
+
"node": ">=12.0.0"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -20,10 +21,6 @@
|
|
|
20
21
|
"bugs": {
|
|
21
22
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
22
23
|
},
|
|
23
|
-
"type": "module",
|
|
24
|
-
"exports": "./build/index.js",
|
|
25
|
-
"types": "./build/index.d.ts",
|
|
26
|
-
"typeScriptVersion": "3.8.3",
|
|
27
24
|
"dependencies": {
|
|
28
25
|
"@cucumber/cucumber": "8.5.1",
|
|
29
26
|
"@cucumber/gherkin": "24.0.0",
|
|
@@ -33,18 +30,20 @@
|
|
|
33
30
|
"@types/long": "^4.0.1",
|
|
34
31
|
"@types/mockery": "^1.4.29",
|
|
35
32
|
"@wdio/logger": "7.19.0",
|
|
36
|
-
"@wdio/types": "7.
|
|
37
|
-
"@wdio/utils": "7.
|
|
33
|
+
"@wdio/types": "7.23.0",
|
|
34
|
+
"@wdio/utils": "7.23.0",
|
|
35
|
+
"expect-webdriverio": "^3.0.0",
|
|
38
36
|
"glob": "^8.0.3",
|
|
39
37
|
"is-glob": "^4.0.0",
|
|
40
38
|
"long": "^4.0.0",
|
|
41
39
|
"mockery": "^2.1.0"
|
|
42
40
|
},
|
|
43
41
|
"peerDependencies": {
|
|
44
|
-
"@wdio/cli": "
|
|
42
|
+
"@wdio/cli": "^7.0.0"
|
|
45
43
|
},
|
|
46
44
|
"publishConfig": {
|
|
47
45
|
"access": "public"
|
|
48
46
|
},
|
|
49
|
-
"
|
|
47
|
+
"types": "./build/index.d.ts",
|
|
48
|
+
"gitHead": "00407ba4e1b414c38195789c748bbad69df1b26d"
|
|
50
49
|
}
|