@zohodesk/testinglibrary 0.1.8 → 0.1.9-exp-actors

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.
Files changed (109) hide show
  1. package/.babelrc +3 -0
  2. package/build/bdd-framework/cli/commands/env.js +1 -1
  3. package/build/bdd-framework/config/configDir.js +35 -0
  4. package/build/bdd-framework/config/enrichReporterData.js +23 -0
  5. package/build/bdd-framework/config/index.js +10 -6
  6. package/build/bdd-framework/cucumber/createTestStep.js +43 -0
  7. package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +126 -0
  8. package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +72 -0
  9. package/build/bdd-framework/cucumber/formatter/PickleParser.js +25 -0
  10. package/build/bdd-framework/cucumber/formatter/durationHelpers.js +13 -0
  11. package/build/bdd-framework/cucumber/formatter/getColorFns.js +57 -0
  12. package/build/bdd-framework/cucumber/formatter/index.js +16 -0
  13. package/build/bdd-framework/cucumber/formatter/locationHelpers.js +16 -0
  14. package/build/bdd-framework/cucumber/loadFeatures.js +62 -31
  15. package/build/bdd-framework/cucumber/loadSteps.js +7 -0
  16. package/build/bdd-framework/cucumber/resolveFeaturePaths.js +62 -0
  17. package/build/bdd-framework/cucumber/stepArguments.js +21 -0
  18. package/build/bdd-framework/cucumber/valueChecker.js +23 -0
  19. package/build/bdd-framework/gen/formatter.js +11 -23
  20. package/build/bdd-framework/gen/index.js +41 -20
  21. package/build/bdd-framework/gen/testFile.js +69 -26
  22. package/build/bdd-framework/gen/testMeta.js +60 -0
  23. package/build/bdd-framework/gen/testNode.js +11 -12
  24. package/build/bdd-framework/hooks/scenario.js +29 -6
  25. package/build/bdd-framework/hooks/worker.js +7 -1
  26. package/build/bdd-framework/index.js +8 -1
  27. package/build/bdd-framework/playwright/getLocationInFile.js +36 -9
  28. package/build/bdd-framework/playwright/loadUtils.js +33 -0
  29. package/build/bdd-framework/playwright/transform.js +5 -1
  30. package/build/bdd-framework/reporter/cucumber/base.js +57 -0
  31. package/build/bdd-framework/reporter/cucumber/custom.js +73 -0
  32. package/build/bdd-framework/reporter/cucumber/helper.js +12 -0
  33. package/build/bdd-framework/reporter/cucumber/html.js +35 -0
  34. package/build/bdd-framework/reporter/cucumber/index.js +74 -0
  35. package/build/bdd-framework/reporter/cucumber/json.js +312 -0
  36. package/build/bdd-framework/reporter/cucumber/junit.js +205 -0
  37. package/build/bdd-framework/reporter/cucumber/message.js +20 -0
  38. package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +64 -0
  39. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +196 -0
  40. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +43 -0
  41. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +52 -0
  42. package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +105 -0
  43. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +70 -0
  44. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +45 -0
  45. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +27 -0
  46. package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +38 -0
  47. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +128 -0
  48. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +126 -0
  49. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +102 -0
  50. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +50 -0
  51. package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +88 -0
  52. package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +30 -0
  53. package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +51 -0
  54. package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +35 -0
  55. package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +5 -0
  56. package/build/bdd-framework/run/StepInvoker.js +21 -26
  57. package/build/bdd-framework/run/bddDataAttachment.js +46 -0
  58. package/build/bdd-framework/run/bddFixtures.js +31 -10
  59. package/build/bdd-framework/run/bddWorld.js +5 -2
  60. package/build/bdd-framework/run/bddWorldInternal.js +15 -0
  61. package/build/bdd-framework/snippets/index.js +3 -7
  62. package/build/bdd-framework/stepDefinitions/defineStep.js +1 -1
  63. package/build/bdd-framework/utils/AutofillMap.js +20 -0
  64. package/build/bdd-framework/utils/index.js +23 -0
  65. package/build/bdd-framework/utils/stripAnsiEscapes.js +20 -0
  66. package/build/core/playwright/builtInFixtures/cacheLayer.js +1 -0
  67. package/build/core/playwright/builtInFixtures/context.js +18 -1
  68. package/build/core/playwright/builtInFixtures/i18N.js +33 -0
  69. package/build/core/playwright/builtInFixtures/index.js +17 -1
  70. package/build/core/playwright/builtInFixtures/page.js +87 -39
  71. package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
  72. package/build/core/playwright/clear-caches.js +19 -8
  73. package/build/core/playwright/codegen.js +4 -4
  74. package/build/core/playwright/constants/browserTypes.js +12 -0
  75. package/build/core/playwright/custom-commands.js +1 -1
  76. package/build/core/playwright/env-initializer.js +10 -6
  77. package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
  78. package/build/core/playwright/helpers/auth/checkAuthCookies.js +50 -0
  79. package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
  80. package/build/core/playwright/helpers/auth/getUsers.js +111 -0
  81. package/build/core/playwright/helpers/auth/index.js +70 -0
  82. package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
  83. package/build/core/playwright/helpers/configFileNameProvider.js +24 -0
  84. package/build/core/playwright/helpers/getUserFixtures.js +23 -0
  85. package/build/core/playwright/helpers/mergeObjects.js +13 -0
  86. package/build/core/playwright/helpers/parseUserArgs.js +11 -0
  87. package/build/core/playwright/index.js +63 -1
  88. package/build/core/playwright/readConfigFile.js +23 -12
  89. package/build/core/playwright/report-generator.js +7 -7
  90. package/build/core/playwright/setup/config-creator.js +4 -1
  91. package/build/core/playwright/setup/config-utils.js +43 -7
  92. package/build/core/playwright/setup/custom-reporter.js +3 -2
  93. package/build/core/playwright/test-runner.js +20 -10
  94. package/build/core/playwright/types.js +43 -0
  95. package/build/index.d.ts +39 -2
  96. package/build/index.js +60 -11
  97. package/build/lib/cli.js +12 -3
  98. package/build/lib/post-install.js +18 -10
  99. package/build/setup-folder-structure/helper.js +3 -0
  100. package/build/setup-folder-structure/samples/auth-setup-sample.js +20 -21
  101. package/build/utils/cliArgsToObject.js +5 -1
  102. package/build/utils/fileUtils.js +3 -0
  103. package/build/utils/rootPath.js +16 -9
  104. package/changelog.md +13 -0
  105. package/npm-shrinkwrap.json +18 -12
  106. package/package.json +6 -4
  107. package/build/bdd-framework/config/dir.js +0 -27
  108. package/build/bdd-framework/cucumber/loadSources.js +0 -57
  109. /package/build/bdd-framework/cucumber/{gherkin.d.js → types.js} +0 -0
@@ -11,6 +11,8 @@ exports.scenarioHookFactory = scenarioHookFactory;
11
11
  var _tagExpressions = _interopRequireDefault(require("@cucumber/tag-expressions"));
12
12
  var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
13
13
  var _utils = require("../utils");
14
+ var _getLocationInFile = require("../playwright/getLocationInFile");
15
+ var _testTypeImpl = require("../playwright/testTypeImpl");
14
16
  /**
15
17
  * Scenario level hooks: Before / After.
16
18
  *
@@ -27,14 +29,16 @@ function scenarioHookFactory(type) {
27
29
  addHook({
28
30
  type,
29
31
  options: getOptionsFromArgs(args),
30
- fn: getFnFromArgs(args)
32
+ fn: getFnFromArgs(args),
33
+ // offset = 3 b/c this call is 3 steps below the user's code
34
+ location: (0, _getLocationInFile.getLocationByOffset)(3)
31
35
  });
32
36
  };
33
37
  }
34
38
  function hasScenarioHooks() {
35
39
  return scenarioHooks.length > 0;
36
40
  }
37
- // eslint-disable-next-line complexity
41
+ // eslint-disable-next-line complexity, max-statements
38
42
  async function runScenarioHooks(type, fixtures) {
39
43
  let error;
40
44
  for (const hook of scenarioHooks) {
@@ -44,11 +48,9 @@ async function runScenarioHooks(type, fixtures) {
44
48
  if (hook.tagsExpression && !hook.tagsExpression.evaluate(fixtures.$tags)) {
45
49
  continue;
46
50
  }
47
- const {
48
- timeout
49
- } = hook.options;
50
51
  try {
51
- await (0, _utils.callWithTimeout)(() => hook.fn.call(fixtures.$bddWorld, fixtures), timeout, `${type} hook timeout (${timeout} ms)`);
52
+ const hookFn = wrapHookFn(hook, fixtures);
53
+ await (0, _testTypeImpl.runStepWithCustomLocation)(fixtures.$bddWorld.test, hook.options.name || '', hook.location, hookFn);
52
54
  } catch (e) {
53
55
  if (type === 'before') {
54
56
  throw e;
@@ -77,6 +79,20 @@ function getScenarioHooksFixtures() {
77
79
  }
78
80
  return scenarioHooksFixtures;
79
81
  }
82
+ /**
83
+ * Wraps hook fn with timeout and waiting Cucumber attachments to fulfill.
84
+ */
85
+ function wrapHookFn(hook, fixtures) {
86
+ const {
87
+ timeout
88
+ } = hook.options;
89
+ const {
90
+ $bddWorld
91
+ } = fixtures;
92
+ return async () => {
93
+ await (0, _utils.callWithTimeout)(() => hook.fn.call($bddWorld, fixtures), timeout, getTimeoutMessage(hook));
94
+ };
95
+ }
80
96
  function getOptionsFromArgs(args) {
81
97
  if (typeof args[0] === 'string') {
82
98
  return {
@@ -104,4 +120,11 @@ function addHook(hook) {
104
120
  // 'after' hooks run in reverse order
105
121
  scenarioHooks.unshift(hook);
106
122
  }
123
+ }
124
+ function getTimeoutMessage(hook) {
125
+ const {
126
+ timeout,
127
+ name: hookName
128
+ } = hook.options;
129
+ return `${hook.type} hook ${hookName ? `"${hookName}" ` : ''}timeout (${timeout} ms)`;
107
130
  }
@@ -37,7 +37,7 @@ async function runWorkerHooks(type, fixtures) {
37
37
  timeout
38
38
  } = hook.options;
39
39
  try {
40
- await (0, _utils.callWithTimeout)(() => hook.fn(fixtures), timeout, `${type} hook timeout (${timeout} ms)`);
40
+ await (0, _utils.callWithTimeout)(() => hook.fn(fixtures), timeout, getTimeoutMessage(hook));
41
41
  } catch (e) {
42
42
  if (type === 'beforeAll') {
43
43
  throw e;
@@ -80,4 +80,10 @@ function addHook(hook) {
80
80
  // 'afterAll' hooks run in reverse order
81
81
  workerHooks.unshift(hook);
82
82
  }
83
+ }
84
+ function getTimeoutMessage(hook) {
85
+ const {
86
+ timeout
87
+ } = hook.options;
88
+ return `${hook.type} hook timeout (${timeout} ms)`;
83
89
  }
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "createBdd", {
27
27
  return _createBdd.createBdd;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "cucumberReporter", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _helper.cucumberReporter;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "defineBddConfig", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -42,4 +48,5 @@ Object.defineProperty(exports, "test", {
42
48
  var _config = require("./config");
43
49
  var _createBdd = require("./stepDefinitions/createBdd");
44
50
  var _bddFixtures = require("./run/bddFixtures");
45
- var _bddWorld = require("./run/bddWorld");
51
+ var _bddWorld = require("./run/bddWorld");
52
+ var _helper = require("./reporter/cucumber/helper");
@@ -4,33 +4,60 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.getLocationByOffset = getLocationByOffset;
7
8
  exports.getLocationInFile = getLocationInFile;
8
9
  var _url = _interopRequireDefault(require("url"));
9
10
  var _utils = require("./utils");
10
11
  /**
11
- * Inspects stacktrace and finds call location in provided file.
12
- * This function is based on Playwright's getLocationByStacktrace().
13
- * See: https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/common/transform.ts#L229
12
+ * Finds first frame in the callstack that matches provided file.
13
+ * Constructs location object from that frame.
14
+ *
15
+ * Example:
16
+ * Calling getLocationInFile('file-3.js');
17
+ * Call stack:
18
+ * - at <anonymous> (file-1.js:1:2)
19
+ * - at myFunction2 (file-2.js:3:4)
20
+ * - at myFunction3 (file-3.js:5:6)
21
+ * - at myFunction4 (file-4.js:7:8)
22
+ *
23
+ * Returned value: { file: 'file-3.js', line: 5, column: 6 }
14
24
  */
15
25
  function getLocationInFile(filePath) {
16
26
  const filePathUrl = _url.default.pathToFileURL(filePath).toString();
27
+ return getLocationBy(stackFrames => {
28
+ return stackFrames.find(frame => {
29
+ const frameFile = frame.getFileName();
30
+ return frameFile === filePath || frameFile === filePathUrl;
31
+ });
32
+ });
33
+ }
34
+ function getLocationByOffset(offset) {
35
+ return getLocationBy(stackFrames => stackFrames[offset]);
36
+ }
37
+ /**
38
+ * Iterates stacktrace of the call of this function
39
+ * and finds frame using provided findFrame predicate.
40
+ * Constructs location object from the found frame.
41
+ *
42
+ * This function is based on Playwright's wrapFunctionWithLocation().
43
+ * See: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/transform/transform.ts#L261
44
+ */
45
+ function getLocationBy(findFrame) {
17
46
  const {
18
47
  sourceMapSupport
19
48
  } = (0, _utils.requirePlaywrightModule)('lib/utilsBundle.js');
20
49
  const oldPrepareStackTrace = Error.prepareStackTrace;
50
+ // modify prepareStackTrace to return Location object instead of string
21
51
  Error.prepareStackTrace = (error, stackFrames) => {
22
- const frameInFile = stackFrames.find(frame => {
23
- const frameFile = frame.getFileName();
24
- return frameFile === filePath || frameFile === filePathUrl;
25
- });
26
- if (!frameInFile) {
52
+ const foundFrame = findFrame(stackFrames);
53
+ if (!foundFrame) {
27
54
  return {
28
55
  file: '',
29
56
  line: 0,
30
57
  column: 0
31
58
  };
32
59
  }
33
- const frame = sourceMapSupport.wrapCallSite(frameInFile);
60
+ const frame = sourceMapSupport.wrapCallSite(foundFrame);
34
61
  const fileName = frame.getFileName();
35
62
  // Node error stacks for modules use file:// urls instead of paths.
36
63
  const file = fileName !== null && fileName !== void 0 && fileName.startsWith('file://') ? _url.default.fileURLToPath(fileName) : fileName;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.requireOrImportDefaultFunction = requireOrImportDefaultFunction;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _transform = require("./transform");
10
+ /**
11
+ * Partial from: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/runner/loadUtils.ts
12
+ */
13
+ /* eslint-disable complexity */
14
+
15
+ async function requireOrImportDefaultFunction(file, expectConstructor) {
16
+ let func = await (0, _transform.requireTransform)().requireOrImport(file);
17
+ if (func && typeof func === 'object' && 'default' in func) {
18
+ func = func['default'];
19
+ }
20
+ if (typeof func !== 'function') {
21
+ throw errorWithFile(file, `file must export a single ${expectConstructor ? 'class' : 'function'}.`);
22
+ }
23
+ return func;
24
+ }
25
+ function relativeFilePath(file) {
26
+ if (!_path.default.isAbsolute(file)) {
27
+ return file;
28
+ }
29
+ return _path.default.relative(process.cwd(), file);
30
+ }
31
+ function errorWithFile(file, message) {
32
+ return new Error(`${relativeFilePath(file)}: ${message}`);
33
+ }
@@ -41,7 +41,11 @@ function installTransform() {
41
41
  if (!shouldTransform(filename)) {
42
42
  return code;
43
43
  }
44
- return transformHook(code, filename);
44
+ // Since PW 1.42 transformHook returns { code, serializedCache } instead of code string
45
+ // See: https://github.com/microsoft/playwright/commit/f605a5009b3c75746120a6ec6d940f62624af5ec#diff-0f8a2f313f1572108f59a6e84663858ebb4fc455163410526b56878794001103
46
+ // See: https://github.com/vitalets/playwright-bdd/issues/96
47
+ const res = transformHook(code, filename);
48
+ return typeof res === 'string' ? res : res.code;
45
49
  }, {
46
50
  exts: ['.ts', '.tsx', '.js', '.jsx', '.mjs']
47
51
  });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _stream = require("stream");
11
+ /**
12
+ * Base reporter for Cucumber reporters.
13
+ * Reference: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/index.ts
14
+ */
15
+
16
+ // Import pipeline from the 'stream' module
17
+
18
+ class BaseReporter {
19
+ internalOptions;
20
+ outputStream = process.stdout;
21
+ constructor(internalOptions) {
22
+ this.internalOptions = internalOptions;
23
+ }
24
+ get eventBroadcaster() {
25
+ return this.internalOptions.eventBroadcaster;
26
+ }
27
+ get eventDataCollector() {
28
+ return this.internalOptions.eventDataCollector;
29
+ }
30
+ printsToStdio() {
31
+ return isStdout(this.outputStream);
32
+ }
33
+ async init() {}
34
+ async finished() {
35
+ if (!isStdout(this.outputStream)) {
36
+ this.outputStream.end();
37
+ await new Promise((resolve, reject) => {
38
+ this.outputStream.on('finish', resolve);
39
+ this.outputStream.on('error', reject);
40
+ });
41
+ }
42
+ }
43
+ setOutputStream(outputFile) {
44
+ if (!outputFile) {
45
+ return;
46
+ }
47
+ const absolutePath = _path.default.resolve(this.internalOptions.cwd, outputFile);
48
+ _fs.default.mkdirSync(_path.default.dirname(absolutePath), {
49
+ recursive: true
50
+ });
51
+ this.outputStream = _fs.default.createWriteStream(absolutePath);
52
+ }
53
+ }
54
+ exports.default = BaseReporter;
55
+ function isStdout(stream) {
56
+ return stream === process.stdout;
57
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _base = _interopRequireDefault(require("./base"));
9
+ var _loadUtils = require("../../playwright/loadUtils");
10
+ var _getColorFns = _interopRequireDefault(require("../../cucumber/formatter/getColorFns"));
11
+ /**
12
+ * Custom Cucumber reporter.
13
+ * See: https://github.com/cucumber/cucumber-js/blob/main/docs/custom_formatters.md
14
+ */
15
+
16
+ class CustomReporter extends _base.default {
17
+ reporterPathOrModule;
18
+ userOptions;
19
+ formatter;
20
+ constructor(internalOptions, reporterPathOrModule, userOptions = {}) {
21
+ super(internalOptions);
22
+ this.reporterPathOrModule = reporterPathOrModule;
23
+ this.userOptions = userOptions;
24
+ this.setOutputStream(this.userOptions.outputFile);
25
+ }
26
+ printsToStdio() {
27
+ // currently always return true, b/c loading of custom reporter is async,
28
+ // but printsToStdio() is called synchronously at the beginning.
29
+ return true;
30
+ }
31
+ async init() {
32
+ const formatterOptions = this.buildFormatterOptions();
33
+ const FormatterConstructor = await this.loadFormatterFromFile();
34
+ this.formatter = new FormatterConstructor(formatterOptions);
35
+ }
36
+ async finished() {
37
+ var _this$formatter;
38
+ await ((_this$formatter = this.formatter) === null || _this$formatter === void 0 ? void 0 : _this$formatter.finished());
39
+ await super.finished();
40
+ }
41
+ async loadFormatterFromFile() {
42
+ // see: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/common/config.ts#L225
43
+ const reporterPath = require.resolve(this.reporterPathOrModule, {
44
+ paths: [this.internalOptions.cwd]
45
+ });
46
+ return (0, _loadUtils.requireOrImportDefaultFunction)(reporterPath, true);
47
+ }
48
+ buildFormatterOptions() {
49
+ const colorFns = (0, _getColorFns.default)(this.outputStream, process.env, this.userOptions.colorsEnabled);
50
+ return {
51
+ cwd: this.internalOptions.cwd,
52
+ eventBroadcaster: this.eventBroadcaster,
53
+ eventDataCollector: this.eventDataCollector,
54
+ parsedArgvOptions: this.userOptions,
55
+ colorFns,
56
+ stream: this.outputStream,
57
+ log: this.outputStream.write.bind(this.outputStream),
58
+ cleanup: async () => {},
59
+ snippetBuilder: null,
60
+ supportCodeLibrary: {
61
+ World: {}
62
+ }
63
+ };
64
+ }
65
+ }
66
+ // const fakeSuportCodeLibrary = {
67
+ // parameterTypeRegistry: ParameterTypeRegistry;
68
+ // stepDefinitions: StepDefinition[];
69
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ // World: any;
71
+ // originalCoordinates: ISupportCodeCoordinates;
72
+ // }
73
+ exports.default = CustomReporter;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cucumberReporter = cucumberReporter;
7
+ function cucumberReporter(type, userOptions) {
8
+ return ['../../../bdd-framework/reporter/cucumber/index.js', {
9
+ $type: type,
10
+ ...(userOptions || {})
11
+ }];
12
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _htmlFormatter = _interopRequireDefault(require("@cucumber/html-formatter"));
9
+ var _utils = require("../../utils");
10
+ var _path = _interopRequireDefault(require("path"));
11
+ var _base = _interopRequireDefault(require("./base"));
12
+ class HtmlReporter extends _base.default {
13
+ userOptions;
14
+ htmlStream;
15
+ constructor(internalOptions, userOptions = {}) {
16
+ super(internalOptions);
17
+ this.userOptions = userOptions;
18
+ this.setOutputStream(this.userOptions.outputFile);
19
+ const packageRoot = (0, _utils.resolvePackageRoot)('@cucumber/html-formatter');
20
+ this.htmlStream = new _htmlFormatter.default(_path.default.join(packageRoot, 'dist/main.css'), _path.default.join(packageRoot, 'dist/main.js'));
21
+ this.eventBroadcaster.on('envelope', envelope => {
22
+ this.htmlStream.write(envelope);
23
+ });
24
+ this.htmlStream.pipe(this.outputStream);
25
+ }
26
+ async finished() {
27
+ this.htmlStream.end();
28
+ await new Promise((resolve, reject) => {
29
+ this.htmlStream.on('finish', resolve);
30
+ this.htmlStream.on('error', reject);
31
+ });
32
+ await super.finished();
33
+ }
34
+ }
35
+ exports.default = HtmlReporter;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _events = _interopRequireDefault(require("events"));
9
+ var _messagesBuilder = require("./messagesBuilder");
10
+ var _configDir = require("../../config/configDir");
11
+ var _enrichReporterData = require("../../config/enrichReporterData");
12
+ var _message = _interopRequireDefault(require("./message"));
13
+ var _html = _interopRequireDefault(require("./html"));
14
+ var _junit = _interopRequireDefault(require("./junit"));
15
+ var _json = _interopRequireDefault(require("./json"));
16
+ var _custom = _interopRequireDefault(require("./custom"));
17
+ /**
18
+ * Playwright reporter that generates different Cucumber reports.
19
+ */
20
+
21
+ const builtinReporters = {
22
+ html: _html.default,
23
+ message: _message.default,
24
+ junit: _junit.default,
25
+ json: _json.default
26
+ };
27
+ class CucumberReporterAdapter {
28
+ messagesBuilderRef;
29
+ type;
30
+ userOptions;
31
+ reporter;
32
+ constructor(fullOptions) {
33
+ const {
34
+ $type,
35
+ ...userOptions
36
+ } = fullOptions;
37
+ this.type = $type;
38
+ this.userOptions = userOptions;
39
+ (0, _enrichReporterData.enableEnrichReporterData)();
40
+ this.messagesBuilderRef = (0, _messagesBuilder.getMessagesBuilderRef)();
41
+ this.reporter = this.createCucumberReporter();
42
+ }
43
+ printsToStdio() {
44
+ return this.reporter.printsToStdio();
45
+ }
46
+ onTestEnd(test, result) {
47
+ this.messagesBuilderRef.onTestEnd(test, result);
48
+ }
49
+ async onEnd(result) {
50
+ this.messagesBuilderRef.onEnd(result);
51
+ await this.reporter.init();
52
+ await this.messagesBuilderRef.builder.buildMessages();
53
+ this.messagesBuilderRef.builder.emitMessages(this.reporter.eventBroadcaster);
54
+ await this.reporter.finished();
55
+ }
56
+ createCucumberReporter() {
57
+ const internalOptions = {
58
+ cwd: (0, _configDir.getPlaywrightConfigDir)(),
59
+ eventBroadcaster: new _events.default(),
60
+ eventDataCollector: this.messagesBuilderRef.builder.eventDataCollector
61
+ };
62
+ if (isBuiltInReporter(this.type)) {
63
+ const BuiltInReporter = builtinReporters[this.type];
64
+ return new BuiltInReporter(internalOptions, this.userOptions);
65
+ } else {
66
+ const reporterPath = this.type;
67
+ return new _custom.default(internalOptions, reporterPath, this.userOptions);
68
+ }
69
+ }
70
+ }
71
+ exports.default = CucumberReporterAdapter;
72
+ function isBuiltInReporter(type) {
73
+ return type in builtinReporters;
74
+ }