@wdio/cucumber-framework 7.20.8 → 8.0.0-alpha.213

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.
@@ -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;
@@ -1 +1 @@
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"}
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"}
@@ -1,8 +1,5 @@
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 = {
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: exports.DEFAULT_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
- exports.NOOP = NOOP;
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,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,oBA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B,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
- "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 {
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 === null || tc === void 0 ? void 0 : tc.pickleId));
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 === (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;
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 = (0, utils_1.addKeywordToStep)(scenario.steps, feature);
278
+ scenario.steps = addKeywordToStep(scenario.steps, feature);
284
279
  }
285
280
  this._currentPickle = { uri, feature, scenario };
286
281
  let reporterScenario = scenario;
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);
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 === 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;
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
- 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;
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 === (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;
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 => { 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));
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 !== 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;
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 === null || doc === void 0 ? void 0 : doc.uri, doc === null || doc === void 0 ? void 0 : doc.feature, scenario, finalResult);
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]) => (0, utils_1.filterPickles)(caps, this._scenarios.find(s => s.id === 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,12 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="expect-webdriverio/types/standalone" />
3
- import { EventEmitter } from 'events';
3
+ import { EventEmitter } from 'node:events';
4
4
  import * as Cucumber from '@cucumber/cucumber';
5
5
  import { After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, World, Then, When } from '@cucumber/cucumber';
6
6
  import { Long } from 'long';
7
7
  import type { Capabilities, Options } from '@wdio/types';
8
8
  import type ExpectWebdriverIO from 'expect-webdriverio';
9
- import { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types';
9
+ import type { CucumberOptions, StepDefinitionOptions, HookFunctionExtension as HookFunctionExtensionImport } from './types';
10
10
  declare class CucumberAdapter {
11
11
  private _cid;
12
12
  private _config;
@@ -41,9 +41,9 @@ declare class CucumberAdapter {
41
41
  * Or pass your own function
42
42
  * Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
43
43
  */
44
- registerRequiredModules(): void;
44
+ registerRequiredModules(): Promise<void>[];
45
45
  requiredFiles(): string[];
46
- loadSpecFiles(): void;
46
+ loadSpecFiles(): Promise<void>;
47
47
  /**
48
48
  * set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
49
49
  * @param {object} config config
@@ -1 +1 @@
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,mBAAm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J;CACJ"}
package/build/index.js CHANGED
@@ -1,69 +1,27 @@
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;
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 { setOptions } from 'expect-webdriverio';
13
+ import CucumberReporter from './reporter.js';
14
+ import { DEFAULT_OPTS } from './constants.js';
15
+ import { setUserHookNames } from './utils.js';
16
+ const require = createRequire(import.meta.url);
17
+ const EventDataCollector = require('@cucumber/cucumber/lib/formatter/helpers/event_data_collector').default;
18
+ const FILE_PROTOCOL = 'file://';
19
+ const { incrementing } = IdGenerator;
61
20
  function getResultObject(world) {
62
- var _a, _b, _c, _d, _e;
63
21
  return {
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
22
+ passed: (world.result?.status === Cucumber.Status.PASSED || world.result?.status === Cucumber.Status.SKIPPED),
23
+ error: world.result?.message,
24
+ duration: world.result?.duration?.nanos / 1e6 // convert into ms
67
25
  };
68
26
  }
69
27
  class CucumberAdapter {
@@ -75,12 +33,17 @@ class CucumberAdapter {
75
33
  this._reporter = _reporter;
76
34
  this._cwd = process.cwd();
77
35
  this._newId = incrementing();
78
- this._cucumberOpts = Object.assign({}, constants_1.DEFAULT_OPTS, this._config.cucumberOpts);
36
+ this._cucumberOpts = Object.assign({}, DEFAULT_OPTS, this._config.cucumberOpts);
79
37
  this._hasTests = true;
80
38
  this._cucumberFeaturesWithLineNumbers = this._config.cucumberFeaturesWithLineNumbers || [];
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;
39
+ this._eventBroadcaster = new EventEmitter();
40
+ this._eventDataCollector = new EventDataCollector(this._eventBroadcaster);
41
+ this._specs = this._specs.map((spec) => (spec.startsWith(FILE_PROTOCOL)
42
+ ? spec.slice(FILE_PROTOCOL.length)
43
+ : spec));
44
+ const featurePathsToRun = this._cucumberFeaturesWithLineNumbers.length > 0
45
+ ? this._cucumberFeaturesWithLineNumbers
46
+ : this._specs;
84
47
  this._pickleFilter = new Cucumber.PickleFilter({
85
48
  cwd: this._cwd,
86
49
  featurePaths: featurePathsToRun,
@@ -94,11 +57,11 @@ class CucumberAdapter {
94
57
  tagsInTitle: Boolean(this._cucumberOpts.tagsInTitle),
95
58
  scenarioLevelReporter: Boolean(this._cucumberOpts.scenarioLevelReporter)
96
59
  };
97
- this._cucumberReporter = new reporter_1.default(this._eventBroadcaster, this._pickleFilter, reporterOptions, this._cid, this._specs, this._reporter);
60
+ this._cucumberReporter = new CucumberReporter(this._eventBroadcaster, this._pickleFilter, reporterOptions, this._cid, this._specs, this._reporter);
98
61
  }
99
62
  async init() {
100
63
  try {
101
- const gherkinMessageStream = gherkin_streams_1.GherkinStreams.fromPaths(this._specs, {
64
+ const gherkinMessageStream = GherkinStreams.fromPaths(this._specs, {
102
65
  defaultDialect: this._cucumberOpts.featureDefaultLanguage,
103
66
  newId: this._newId
104
67
  });
@@ -113,14 +76,13 @@ class CucumberAdapter {
113
76
  this._hasTests = this._cucumberReporter.eventListener.getPickleIds(this._capabilities).length > 0;
114
77
  }
115
78
  catch (runtimeError) {
116
- await (0, utils_1.executeHooksWithArgs)('after', this._config.after, [runtimeError, this._capabilities, this._specs]);
79
+ await executeHooksWithArgs('after', this._config.after, [runtimeError, this._capabilities, this._specs]);
117
80
  throw runtimeError;
118
81
  }
119
82
  /**
120
83
  * import and set options for `expect-webdriverio` assertion lib once
121
84
  * the framework was initiated so that it can detect the environment
122
85
  */
123
- const { setOptions } = require('expect-webdriverio');
124
86
  setOptions({
125
87
  wait: this._config.waitforTimeout,
126
88
  interval: this._config.waitforInterval, // interval between attempts
@@ -134,19 +96,19 @@ class CucumberAdapter {
134
96
  let runtimeError;
135
97
  let result;
136
98
  try {
137
- this.registerRequiredModules();
99
+ await this.registerRequiredModules();
138
100
  Cucumber.supportCodeLibraryBuilder.reset(this._cwd, this._newId);
139
101
  /**
140
102
  * wdio hooks should be added before spec files are loaded
141
103
  */
142
104
  this.addWdioHooks(this._config);
143
- this.loadSpecFiles();
105
+ await this.loadSpecFiles();
144
106
  this.wrapSteps(this._config);
145
107
  /**
146
108
  * we need to somehow identify is function is step or hook
147
109
  * so we wrap every user hook function
148
110
  */
149
- (0, utils_2.setUserHookNames)(Cucumber.supportCodeLibraryBuilder);
111
+ setUserHookNames(Cucumber.supportCodeLibraryBuilder);
150
112
  Cucumber.setDefaultTimeout(this._cucumberOpts.timeout);
151
113
  const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize();
152
114
  /**
@@ -178,7 +140,7 @@ class CucumberAdapter {
178
140
  runtimeError = err;
179
141
  result = 1;
180
142
  }
181
- await (0, utils_1.executeHooksWithArgs)('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
143
+ await executeHooksWithArgs('after', this._config.after, [runtimeError || result, this._capabilities, this._specs]);
182
144
  /**
183
145
  * in case the spec has a runtime error throw after the wdio hook
184
146
  */
@@ -197,71 +159,70 @@ class CucumberAdapter {
197
159
  * Usage: `[() => { require('@babel/register')({ ignore: [] }) }]`
198
160
  */
199
161
  registerRequiredModules() {
200
- this._cucumberOpts.requireModule.map(requiredModule => {
162
+ return this._cucumberOpts.requireModule.map(async (requiredModule) => {
201
163
  if (Array.isArray(requiredModule)) {
202
- require(requiredModule[0])(requiredModule[1]);
164
+ (await import(requiredModule[0]))(requiredModule[1]);
203
165
  }
204
166
  else if (typeof requiredModule === 'function') {
205
167
  requiredModule();
206
168
  }
207
169
  else {
208
- require(requiredModule);
170
+ await import(requiredModule);
209
171
  }
210
172
  });
211
173
  }
212
174
  requiredFiles() {
213
- return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat((0, is_glob_1.default)(requiredFile)
214
- ? glob_1.default.sync(requiredFile)
175
+ return this._cucumberOpts.require.reduce((files, requiredFile) => files.concat(isGlob(requiredFile)
176
+ ? glob.sync(requiredFile)
215
177
  : [requiredFile]), []);
216
178
  }
217
- loadSpecFiles() {
179
+ async loadSpecFiles() {
218
180
  // we use mockery to allow people to import 'our' cucumber even though their spec files are in their folders
219
181
  // because of that we don't have to attach anything to the global object, and the current cucumber spec files
220
182
  // should just work with no changes with this framework
221
- mockery_1.default.enable({
183
+ mockery.enable({
222
184
  useCleanCache: false,
223
185
  warnOnReplace: false,
224
186
  warnOnUnregistered: false
225
187
  });
226
- mockery_1.default.registerMock('@cucumber/cucumber', Cucumber);
227
- this.requiredFiles().forEach((codePath) => {
228
- const filepath = path_1.default.isAbsolute(codePath)
188
+ mockery.registerMock('@cucumber/cucumber', Cucumber);
189
+ await Promise.all(this.requiredFiles().map((codePath) => {
190
+ const filepath = path.isAbsolute(codePath)
229
191
  ? codePath
230
- : path_1.default.join(process.cwd(), codePath);
192
+ : path.join(process.cwd(), codePath);
231
193
  // This allows rerunning a stepDefinitions file
232
194
  delete require.cache[require.resolve(filepath)];
233
- require(filepath);
234
- });
235
- mockery_1.default.disable();
195
+ return import(filepath);
196
+ }));
197
+ mockery.disable();
236
198
  }
237
199
  /**
238
200
  * set `beforeFeature`, `afterFeature`, `beforeScenario`, `afterScenario`, 'beforeStep', 'afterStep'
239
201
  * @param {object} config config
240
202
  */
241
203
  addWdioHooks(config) {
242
- var _a;
243
- const eventListener = (_a = this._cucumberReporter) === null || _a === void 0 ? void 0 : _a.eventListener;
204
+ const eventListener = this._cucumberReporter?.eventListener;
244
205
  Cucumber.BeforeAll(async function wdioHookBeforeFeature() {
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]);
206
+ const params = eventListener?.getHookParams();
207
+ await executeHooksWithArgs('beforeFeature', config.beforeFeature, [params?.uri, params?.feature]);
247
208
  });
248
209
  Cucumber.AfterAll(async function wdioHookAfterFeature() {
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]);
210
+ const params = eventListener?.getHookParams();
211
+ await executeHooksWithArgs('afterFeature', config.afterFeature, [params?.uri, params?.feature]);
251
212
  });
252
213
  Cucumber.Before(async function wdioHookBeforeScenario(world) {
253
- await (0, utils_1.executeHooksWithArgs)('beforeScenario', config.beforeScenario, [world, this]);
214
+ await executeHooksWithArgs('beforeScenario', config.beforeScenario, [world, this]);
254
215
  });
255
216
  Cucumber.After(async function wdioHookAfterScenario(world) {
256
- await (0, utils_1.executeHooksWithArgs)('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
217
+ await executeHooksWithArgs('afterScenario', config.afterScenario, [world, getResultObject(world), this]);
257
218
  });
258
219
  Cucumber.BeforeStep(async function wdioHookBeforeStep() {
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]);
220
+ const params = eventListener?.getHookParams();
221
+ await executeHooksWithArgs('beforeStep', config.beforeStep, [params?.step, params?.scenario, this]);
261
222
  });
262
223
  Cucumber.AfterStep(async function wdioHookAfterStep(world) {
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]);
224
+ const params = eventListener?.getHookParams();
225
+ await executeHooksWithArgs('afterStep', config.afterStep, [params?.step, params?.scenario, getResultObject(world), this]);
265
226
  });
266
227
  }
267
228
  /**
@@ -307,14 +268,12 @@ class CucumberAdapter {
307
268
  */
308
269
  const beforeFn = config.beforeHook;
309
270
  const afterFn = config.afterHook;
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);
271
+ 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
272
  };
312
273
  }
313
274
  }
314
- exports.CucumberAdapter = CucumberAdapter;
315
275
  const _CucumberAdapter = CucumberAdapter;
316
276
  const adapterFactory = {};
317
- exports.adapterFactory = adapterFactory;
318
277
  /**
319
278
  * tested by smoke tests
320
279
  */
@@ -325,4 +284,5 @@ adapterFactory.init = async function (...args) {
325
284
  const instance = await adapter.init();
326
285
  return instance;
327
286
  };
328
- exports.default = adapterFactory;
287
+ export default adapterFactory;
288
+ export { CucumberAdapter, adapterFactory, After, AfterAll, AfterStep, Before, BeforeAll, BeforeStep, DataTable, defineParameterType, defineStep, Given, setDefaultTimeout, setDefinitionFunctionWrapper, setWorldConstructor, Then, When, World };
@@ -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
- import { ReporterScenario } from './constants';
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
@@ -1 +1 @@
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,CAA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AAE,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
- "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 {
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 cucumberEventListener_1.default(eventBroadcaster, pickleFilter)
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: (0, utils_1.getFeatureId)(uri, feature),
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: (0, utils_1.getFeatureId)(uri, feature),
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 = (0, utils_1.getStepType)(step);
57
- const payload = (0, utils_1.buildStepPayload)(uri, feature, scenario, step, { type });
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 = (0, utils_1.getStepType)(step);
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 = (0, utils_1.buildStepPayload)(uri, feature, scenario, step, {
68
+ const payload = buildStepPayload(uri, feature, scenario, step, {
75
69
  type: 'hook',
76
70
  state: result.status,
77
71
  error,
78
- duration: Date.now() - ((_a = this._testStart) === null || _a === void 0 ? void 0 : _a.getTime())
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 cucumber_1.Status.FAILED:
87
- case cucumber_1.Status.UNDEFINED:
79
+ case Status.FAILED:
80
+ case Status.UNDEFINED:
88
81
  state = 'fail';
89
82
  break;
90
- case cucumber_1.Status.PASSED:
83
+ case Status.PASSED:
91
84
  state = 'pass';
92
85
  break;
93
- case cucumber_1.Status.PENDING:
86
+ case Status.PENDING:
94
87
  state = 'pending';
95
88
  break;
96
- case cucumber_1.Status.SKIPPED:
89
+ case Status.SKIPPED:
97
90
  state = 'skip';
98
91
  break;
99
- case cucumber_1.Status.AMBIGUOUS:
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 === null || step === void 0 ? void 0 : step.text
98
+ ? step?.text
106
99
  : this.getTitle(scenario);
107
- if (result.status === cucumber_1.Status.UNDEFINED) {
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 = (_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]; });
116
+ const featChildren = feature.children?.find(c => scenario.astNodeIds && c.scenario?.id === scenario.astNodeIds[0]);
124
117
  if (featChildren) {
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]);
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}):${(_j = featStep.location) === null || _j === void 0 ? void 0 : _j.line}:${(_k = featStep.location) === null || _k === void 0 ? void 0 : _k.column}\n`;
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 === cucumber_1.Status.FAILED && !result.willBeRetried) {
135
- error = new Error((_l = result.message) === null || _l === void 0 ? void 0 : _l.split('\n')[0]);
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 === cucumber_1.Status.AMBIGUOUS && this._options.failAmbiguousDefinitions) {
132
+ else if (result.status === Status.AMBIGUOUS && this._options.failAmbiguousDefinitions) {
140
133
  state = 'fail';
141
134
  this.failedCount++;
142
- error = new Error((_m = result.message) === null || _m === void 0 ? void 0 : _m.split('\n')[0]);
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() - ((_o = this._testStart) === null || _o === void 0 ? void 0 : _o.getTime()),
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
- ? (0, utils_1.buildStepPayload)(uri, feature, scenario, step, {
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: (0, utils_1.getFeatureId)(uri, feature),
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: (0, utils_1.getFeatureId)(uri, feature),
170
+ parent: getFeatureId(uri, feature),
179
171
  type: 'scenario',
180
172
  file: uri,
181
- duration: Date.now() - ((_a = this._scenarioStart) === null || _a === void 0 ? void 0 : _a.getTime()),
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: (0, utils_1.getFeatureId)(uri, feature),
179
+ uid: getFeatureId(uri, feature),
189
180
  title: this.getTitle(feature),
190
181
  type: 'feature',
191
182
  file: uri,
192
- duration: Date.now() - ((_a = this._featureStart) === null || _a === void 0 ? void 0 : _a.getTime()),
183
+ duration: Date.now() - this._featureStart?.getTime(),
193
184
  tags: feature.tags
194
185
  });
195
186
  }
196
187
  emit(event, payload) {
197
- let message = (0, utils_1.formatMessage)({ payload });
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
- "use strict";
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
  */
@@ -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;AAE1C,OAAO,EAAkC,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1E;;GAEG;AACH,wBAAgB,kBAAkB,CAA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AAC,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
- "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');
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: (_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
- })
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
- 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}`;
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
- constants_1.CUCUMBER_HOOK_DEFINITION_TYPES.forEach(hookName => {
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 = ((0, utils_1.isFunctionAsync)(hookFn)) ? userHookAsyncFn : userHookFn;
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 => { var _a; return (_a = p.name) === null || _a === void 0 ? void 0 : _a.match(skipTag); })
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
- var _a, _b;
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
- 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; });
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 (_b = rule === null || rule === void 0 ? void 0 : rule.rule) === null || _b === void 0 ? void 0 : _b.name;
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) => { var _a; return (_a = child.rule) === null || _a === void 0 ? void 0 : _a.children; }).flat();
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.8",
3
+ "version": "8.0.0-alpha.213+c5fb6d57e",
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": ">=12.0.0"
9
+ "node": "^16.13 || >=18"
11
10
  },
12
11
  "repository": {
13
12
  "type": "git",
@@ -21,17 +20,21 @@
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.5.0",
28
+ "@cucumber/cucumber": "8.5.1",
26
29
  "@cucumber/gherkin": "24.0.0",
27
30
  "@cucumber/gherkin-streams": "^5.0.0",
28
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
- "@wdio/logger": "7.19.0",
33
- "@wdio/types": "7.20.7",
34
- "@wdio/utils": "7.20.7",
35
+ "@wdio/logger": "8.0.0-alpha.213+c5fb6d57e",
36
+ "@wdio/types": "8.0.0-alpha.213+c5fb6d57e",
37
+ "@wdio/utils": "8.0.0-alpha.213+c5fb6d57e",
35
38
  "expect-webdriverio": "^3.0.0",
36
39
  "glob": "^8.0.3",
37
40
  "is-glob": "^4.0.0",
@@ -44,6 +47,5 @@
44
47
  "publishConfig": {
45
48
  "access": "public"
46
49
  },
47
- "types": "./build/index.d.ts",
48
- "gitHead": "8ea0ee903b02157b9ee511c8750be2282b4f4519"
50
+ "gitHead": "c5fb6d57e168d8bf939a5aa5c2ada5abaceec5eb"
49
51
  }