@cucumber/cucumber 7.3.0 → 8.0.0-rc.2

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 (197) hide show
  1. package/README.md +11 -4
  2. package/lib/cli/argv_parser.d.ts +3 -3
  3. package/lib/cli/argv_parser.js +19 -19
  4. package/lib/cli/argv_parser.js.map +1 -1
  5. package/lib/cli/configuration_builder.d.ts +5 -46
  6. package/lib/cli/configuration_builder.js +61 -150
  7. package/lib/cli/configuration_builder.js.map +1 -1
  8. package/lib/cli/helpers.d.ts +5 -3
  9. package/lib/cli/helpers.js +42 -15
  10. package/lib/cli/helpers.js.map +1 -1
  11. package/lib/cli/i18n.js +7 -7
  12. package/lib/cli/i18n.js.map +1 -1
  13. package/lib/cli/index.d.ts +4 -23
  14. package/lib/cli/index.js +18 -193
  15. package/lib/cli/index.js.map +1 -1
  16. package/lib/cli/install_validator.js +1 -1
  17. package/lib/cli/install_validator.js.map +1 -1
  18. package/lib/cli/option_splitter.js +1 -0
  19. package/lib/cli/option_splitter.js.map +1 -1
  20. package/lib/cli/profile_loader.d.ts +3 -2
  21. package/lib/cli/profile_loader.js +20 -13
  22. package/lib/cli/profile_loader.js.map +1 -1
  23. package/lib/cli/publish_banner.js +1 -1
  24. package/lib/cli/publish_banner.js.map +1 -1
  25. package/lib/cli/run.js +3 -4
  26. package/lib/cli/run.js.map +1 -1
  27. package/lib/configuration/index.d.ts +1 -0
  28. package/lib/configuration/index.js +14 -0
  29. package/lib/configuration/index.js.map +1 -0
  30. package/lib/configuration/types.d.ts +29 -0
  31. package/lib/configuration/types.js +3 -0
  32. package/lib/configuration/types.js.map +1 -0
  33. package/lib/formatter/builder.d.ts +5 -4
  34. package/lib/formatter/builder.js +41 -55
  35. package/lib/formatter/builder.js.map +1 -1
  36. package/lib/formatter/get_color_fns.d.ts +4 -0
  37. package/lib/formatter/get_color_fns.js +11 -4
  38. package/lib/formatter/get_color_fns.js.map +1 -1
  39. package/lib/formatter/helpers/event_data_collector.d.ts +2 -1
  40. package/lib/formatter/helpers/event_data_collector.js +16 -15
  41. package/lib/formatter/helpers/event_data_collector.js.map +1 -1
  42. package/lib/formatter/helpers/formatters.d.ts +6 -0
  43. package/lib/formatter/helpers/formatters.js +41 -0
  44. package/lib/formatter/helpers/formatters.js.map +1 -0
  45. package/lib/formatter/helpers/gherkin_document_parser.js +29 -42
  46. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
  47. package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
  48. package/lib/formatter/helpers/issue_helpers.js +6 -7
  49. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  50. package/lib/formatter/helpers/keyword_type.js +2 -6
  51. package/lib/formatter/helpers/keyword_type.js.map +1 -1
  52. package/lib/formatter/helpers/location_helpers.js +1 -1
  53. package/lib/formatter/helpers/location_helpers.js.map +1 -1
  54. package/lib/formatter/helpers/pickle_parser.js +9 -18
  55. package/lib/formatter/helpers/pickle_parser.js.map +1 -1
  56. package/lib/formatter/helpers/step_argument_formatter.js +1 -1
  57. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
  58. package/lib/formatter/helpers/summary_helpers.js +8 -7
  59. package/lib/formatter/helpers/summary_helpers.js.map +1 -1
  60. package/lib/formatter/helpers/test_case_attempt_formatter.js +12 -12
  61. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  62. package/lib/formatter/helpers/test_case_attempt_parser.js +17 -20
  63. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  64. package/lib/formatter/helpers/usage_helpers/index.js +26 -40
  65. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  66. package/lib/formatter/html_formatter.d.ts +1 -0
  67. package/lib/formatter/html_formatter.js +5 -4
  68. package/lib/formatter/html_formatter.js.map +1 -1
  69. package/lib/formatter/http_stream.js +7 -7
  70. package/lib/formatter/http_stream.js.map +1 -1
  71. package/lib/formatter/index.d.ts +1 -0
  72. package/lib/formatter/index.js.map +1 -1
  73. package/lib/formatter/json_formatter.d.ts +1 -0
  74. package/lib/formatter/json_formatter.js +25 -20
  75. package/lib/formatter/json_formatter.js.map +1 -1
  76. package/lib/formatter/message_formatter.d.ts +1 -0
  77. package/lib/formatter/message_formatter.js +1 -0
  78. package/lib/formatter/message_formatter.js.map +1 -1
  79. package/lib/formatter/progress_bar_formatter.d.ts +1 -0
  80. package/lib/formatter/progress_bar_formatter.js +17 -16
  81. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  82. package/lib/formatter/progress_formatter.d.ts +1 -0
  83. package/lib/formatter/progress_formatter.js +3 -2
  84. package/lib/formatter/progress_formatter.js.map +1 -1
  85. package/lib/formatter/publish.d.ts +1 -0
  86. package/lib/formatter/publish.js +5 -0
  87. package/lib/formatter/publish.js.map +1 -0
  88. package/lib/formatter/rerun_formatter.d.ts +1 -0
  89. package/lib/formatter/rerun_formatter.js +15 -11
  90. package/lib/formatter/rerun_formatter.js.map +1 -1
  91. package/lib/formatter/snippets_formatter.d.ts +1 -0
  92. package/lib/formatter/snippets_formatter.js +3 -2
  93. package/lib/formatter/snippets_formatter.js.map +1 -1
  94. package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
  95. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
  96. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +3 -0
  97. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
  98. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +1 -1
  99. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -1
  100. package/lib/formatter/summary_formatter.d.ts +1 -0
  101. package/lib/formatter/summary_formatter.js +10 -10
  102. package/lib/formatter/summary_formatter.js.map +1 -1
  103. package/lib/formatter/usage_formatter.d.ts +1 -0
  104. package/lib/formatter/usage_formatter.js +9 -9
  105. package/lib/formatter/usage_formatter.js.map +1 -1
  106. package/lib/formatter/usage_json_formatter.d.ts +1 -0
  107. package/lib/formatter/usage_json_formatter.js +3 -2
  108. package/lib/formatter/usage_json_formatter.js.map +1 -1
  109. package/lib/importer.js +13 -0
  110. package/lib/index.d.ts +2 -0
  111. package/lib/index.js +6 -1
  112. package/lib/index.js.map +1 -1
  113. package/lib/models/data_table.js +9 -7
  114. package/lib/models/data_table.js.map +1 -1
  115. package/lib/models/step_definition.js +4 -5
  116. package/lib/models/step_definition.js.map +1 -1
  117. package/lib/pickle_filter.js +13 -13
  118. package/lib/pickle_filter.js.map +1 -1
  119. package/lib/run/formatters.d.ts +14 -0
  120. package/lib/run/formatters.js +76 -0
  121. package/lib/run/formatters.js.map +1 -0
  122. package/lib/run/index.d.ts +2 -0
  123. package/lib/run/index.js +15 -0
  124. package/lib/run/index.js.map +1 -0
  125. package/lib/run/paths.d.ts +6 -0
  126. package/lib/run/paths.js +83 -0
  127. package/lib/run/paths.js.map +1 -0
  128. package/lib/run/runCucumber.d.ts +3 -0
  129. package/lib/run/runCucumber.js +88 -0
  130. package/lib/run/runCucumber.js.map +1 -0
  131. package/lib/run/runtime.d.ts +19 -0
  132. package/lib/run/runtime.js +58 -0
  133. package/lib/run/runtime.js.map +1 -0
  134. package/lib/run/support.d.ts +8 -0
  135. package/lib/run/support.js +26 -0
  136. package/lib/run/support.js.map +1 -0
  137. package/lib/run/types.d.ts +12 -0
  138. package/lib/run/types.js +3 -0
  139. package/lib/run/types.js.map +1 -0
  140. package/lib/runtime/assemble_test_cases.js +3 -3
  141. package/lib/runtime/assemble_test_cases.js.map +1 -1
  142. package/lib/runtime/attachment_manager/index.js +4 -4
  143. package/lib/runtime/attachment_manager/index.js.map +1 -1
  144. package/lib/runtime/helpers.d.ts +1 -0
  145. package/lib/runtime/helpers.js +42 -4
  146. package/lib/runtime/helpers.js.map +1 -1
  147. package/lib/runtime/index.d.ts +5 -3
  148. package/lib/runtime/index.js +22 -46
  149. package/lib/runtime/index.js.map +1 -1
  150. package/lib/runtime/parallel/coordinator.d.ts +6 -5
  151. package/lib/runtime/parallel/coordinator.js +19 -22
  152. package/lib/runtime/parallel/coordinator.js.map +1 -1
  153. package/lib/runtime/parallel/run_worker.js +1 -1
  154. package/lib/runtime/parallel/run_worker.js.map +1 -1
  155. package/lib/runtime/parallel/worker.js +21 -13
  156. package/lib/runtime/parallel/worker.js.map +1 -1
  157. package/lib/runtime/step_runner.js +5 -7
  158. package/lib/runtime/step_runner.js.map +1 -1
  159. package/lib/runtime/stopwatch.js +4 -4
  160. package/lib/runtime/stopwatch.js.map +1 -1
  161. package/lib/runtime/test_case_runner.d.ts +3 -3
  162. package/lib/runtime/test_case_runner.js +19 -28
  163. package/lib/runtime/test_case_runner.js.map +1 -1
  164. package/lib/stack_trace_filter.js +6 -7
  165. package/lib/stack_trace_filter.js.map +1 -1
  166. package/lib/step_arguments.js +2 -2
  167. package/lib/step_arguments.js.map +1 -1
  168. package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
  169. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  170. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  171. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  172. package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
  173. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  174. package/lib/support_code_library_builder/index.js +18 -31
  175. package/lib/support_code_library_builder/index.js.map +1 -1
  176. package/lib/support_code_library_builder/types.d.ts +2 -1
  177. package/lib/support_code_library_builder/types.js.map +1 -1
  178. package/lib/support_code_library_builder/validate_arguments.js +14 -19
  179. package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
  180. package/lib/time.d.ts +1 -0
  181. package/lib/time.js +17 -2
  182. package/lib/time.js.map +1 -1
  183. package/lib/user_code_runner.js +10 -17
  184. package/lib/user_code_runner.js.map +1 -1
  185. package/lib/value_checker.d.ts +2 -2
  186. package/lib/value_checker.js.map +1 -1
  187. package/lib/version.d.ts +1 -0
  188. package/lib/version.js +6 -0
  189. package/lib/version.js.map +1 -0
  190. package/lib/wrapper.mjs +38 -0
  191. package/package.json +77 -67
  192. package/CHANGELOG.md +0 -1908
  193. package/lib/support_code_library_builder/build_helpers.js +0 -41
  194. package/lib/support_code_library_builder/build_helpers.js.map +0 -1
  195. package/lib/support_code_library_builder/finalize_helpers.d.ts +0 -10
  196. package/lib/support_code_library_builder/finalize_helpers.js +0 -26
  197. package/lib/support_code_library_builder/finalize_helpers.js.map +0 -1
@@ -22,7 +22,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- const lodash_1 = __importDefault(require("lodash"));
26
25
  const _1 = __importDefault(require("./"));
27
26
  const helpers_1 = require("./helpers");
28
27
  const messages = __importStar(require("@cucumber/messages"));
@@ -35,7 +34,7 @@ class JsonFormatter extends _1.default {
35
34
  constructor(options) {
36
35
  super(options);
37
36
  options.eventBroadcaster.on('envelope', (envelope) => {
38
- if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
37
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
39
38
  this.onTestRunFinished();
40
39
  }
41
40
  });
@@ -45,7 +44,9 @@ class JsonFormatter extends _1.default {
45
44
  }
46
45
  formatDataTable(dataTable) {
47
46
  return {
48
- rows: dataTable.rows.map((row) => ({ cells: lodash_1.default.map(row.cells, 'value') })),
47
+ rows: dataTable.rows.map((row) => ({
48
+ cells: row.cells.map((x) => x.value),
49
+ })),
49
50
  };
50
51
  }
51
52
  formatDocString(docString, gherkinStep) {
@@ -55,11 +56,11 @@ class JsonFormatter extends _1.default {
55
56
  };
56
57
  }
57
58
  formatStepArgument(stepArgument, gherkinStep) {
58
- if (value_checker_1.doesNotHaveValue(stepArgument)) {
59
+ if ((0, value_checker_1.doesNotHaveValue)(stepArgument)) {
59
60
  return [];
60
61
  }
61
62
  return [
62
- step_arguments_1.parseStepArgument(stepArgument, {
63
+ (0, step_arguments_1.parseStepArgument)(stepArgument, {
63
64
  dataTable: (dataTable) => this.formatDataTable(dataTable),
64
65
  docString: (docString) => this.formatDocString(docString, gherkinStep),
65
66
  }),
@@ -67,27 +68,30 @@ class JsonFormatter extends _1.default {
67
68
  }
68
69
  onTestRunFinished() {
69
70
  const groupedTestCaseAttempts = {};
70
- lodash_1.default.each(this.eventDataCollector.getTestCaseAttempts(), (testCaseAttempt) => {
71
- if (!testCaseAttempt.worstTestStepResult.willBeRetried) {
71
+ this.eventDataCollector
72
+ .getTestCaseAttempts()
73
+ .forEach((testCaseAttempt) => {
74
+ if (!testCaseAttempt.willBeRetried) {
72
75
  const uri = testCaseAttempt.pickle.uri;
73
- if (value_checker_1.doesNotHaveValue(groupedTestCaseAttempts[uri])) {
76
+ if ((0, value_checker_1.doesNotHaveValue)(groupedTestCaseAttempts[uri])) {
74
77
  groupedTestCaseAttempts[uri] = [];
75
78
  }
76
79
  groupedTestCaseAttempts[uri].push(testCaseAttempt);
77
80
  }
78
81
  });
79
- const features = lodash_1.default.map(groupedTestCaseAttempts, (group, uri) => {
82
+ const features = Object.keys(groupedTestCaseAttempts).map((uri) => {
83
+ const group = groupedTestCaseAttempts[uri];
80
84
  const { gherkinDocument } = group[0];
81
85
  const gherkinStepMap = getGherkinStepMap(gherkinDocument);
82
86
  const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument);
83
- const gherkinExampleRuleMap = gherkin_document_parser_1.getGherkinExampleRuleMap(gherkinDocument);
84
- const gherkinScenarioLocationMap = gherkin_document_parser_1.getGherkinScenarioLocationMap(gherkinDocument);
87
+ const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
88
+ const gherkinScenarioLocationMap = (0, gherkin_document_parser_1.getGherkinScenarioLocationMap)(gherkinDocument);
85
89
  const elements = group.map((testCaseAttempt) => {
86
90
  const { pickle } = testCaseAttempt;
87
91
  const pickleStepMap = getPickleStepMap(pickle);
88
92
  let isBeforeHook = true;
89
93
  const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {
90
- isBeforeHook = isBeforeHook && !value_checker_1.doesHaveValue(testStep.pickleStepId);
94
+ isBeforeHook = isBeforeHook && !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
91
95
  return this.getStepData({
92
96
  isBeforeHook,
93
97
  gherkinStepMap,
@@ -145,7 +149,7 @@ class JsonFormatter extends _1.default {
145
149
  formatScenarioId({ feature, pickle, gherkinExampleRuleMap, }) {
146
150
  let parts;
147
151
  const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
148
- if (value_checker_1.doesHaveValue(rule)) {
152
+ if ((0, value_checker_1.doesHaveValue)(rule)) {
149
153
  parts = [feature, rule, pickle];
150
154
  }
151
155
  else {
@@ -155,7 +159,7 @@ class JsonFormatter extends _1.default {
155
159
  }
156
160
  getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
157
161
  const data = {};
158
- if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
162
+ if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
159
163
  const pickleStep = pickleStepMap[testStep.pickleStepId];
160
164
  data.arguments = this.formatStepArgument(pickleStep.argument, gherkinStepMap[pickleStep.astNodeIds[0]]);
161
165
  data.keyword = getStepKeyword({ pickleStep, gherkinStepMap });
@@ -166,24 +170,24 @@ class JsonFormatter extends _1.default {
166
170
  data.keyword = isBeforeHook ? 'Before' : 'After';
167
171
  data.hidden = true;
168
172
  }
169
- if (value_checker_1.doesHaveValue(testStep.stepDefinitionIds) &&
173
+ if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) &&
170
174
  testStep.stepDefinitionIds.length === 1) {
171
175
  const stepDefinition = this.supportCodeLibrary.stepDefinitions.find((s) => s.id === testStep.stepDefinitionIds[0]);
172
- data.match = { location: helpers_1.formatLocation(stepDefinition) };
176
+ data.match = { location: (0, helpers_1.formatLocation)(stepDefinition) };
173
177
  }
174
178
  const { message, status } = testStepResult;
175
179
  data.result = {
176
180
  status: messages.TestStepResultStatus[status].toLowerCase(),
177
181
  };
178
- if (value_checker_1.doesHaveValue(testStepResult.duration)) {
182
+ if ((0, value_checker_1.doesHaveValue)(testStepResult.duration)) {
179
183
  data.result.duration =
180
184
  messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;
181
185
  }
182
186
  if (status === messages.TestStepResultStatus.FAILED &&
183
- value_checker_1.doesHaveValue(message)) {
187
+ (0, value_checker_1.doesHaveValue)(message)) {
184
188
  data.result.error_message = message;
185
189
  }
186
- if (lodash_1.default.size(testStepAttachments) > 0) {
190
+ if ((testStepAttachments === null || testStepAttachments === void 0 ? void 0 : testStepAttachments.length) > 0) {
187
191
  data.embeddings = testStepAttachments.map((attachment) => ({
188
192
  data: attachment.body,
189
193
  mime_type: attachment.mediaType,
@@ -192,7 +196,7 @@ class JsonFormatter extends _1.default {
192
196
  return data;
193
197
  }
194
198
  getFeatureTags(feature) {
195
- return lodash_1.default.map(feature.tags, (tagData) => ({
199
+ return feature.tags.map((tagData) => ({
196
200
  name: tagData.name,
197
201
  line: tagData.location.line,
198
202
  }));
@@ -218,4 +222,5 @@ class JsonFormatter extends _1.default {
218
222
  }
219
223
  }
220
224
  exports.default = JsonFormatter;
225
+ JsonFormatter.documentation = 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/cucumber/tree/master/json-formatter).';
221
226
  //# sourceMappingURL=json_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,0CAAiD;AACjD,uCAA+E;AAC/E,6DAA8C;AAC9C,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AAErD,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+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c,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAClD,CAAA;IACH,CAAC;IAEO,cAAc,CACpB,OAA2B,EAC3B,OAAyB,EACzB,QAA2B;;QAE3B,MAAM,WAAW,GAAG,CAAC,GAAiB,EAAW,EAAE,CACjD,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAA;QAC9B,MAAM,OAAO,GAAG,CACd,GAAmB,EACnB,GAAmB,EACH,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAEpC,MAAM,GAAG,GACP,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC/B,QAAQ,CAAC,QAAQ;iBACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;iBACnB,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtB,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,IAAI;SAC1B,CAAA;IACH,CAAC;CACF;AAxQD,gCAwQC","sourcesContent":["import _ from 'lodash'\nimport Formatter, { IFormatterOptions } from './'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport * as messages from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst { getScenarioDescription, getPickleStepMap, getStepKeyword } =\n PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.Feature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.Feature\n gherkinScenarioMap: Record<string, messages.Scenario>\n gherkinExampleRuleMap: Record<string, messages.Rule>\n gherkinScenarioLocationMap: Record<string, messages.Location>\n pickle: messages.Pickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: messages.Feature | messages.Pickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({ cells: _.map(row.cells, 'value') })),\n }\n }\n\n formatDocString(\n docString: messages.PickleDocString,\n gherkinStep: messages.Step\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.PickleStepArgument,\n gherkinStep: messages.Step\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n _.each(\n this.eventDataCollector.getTestCaseAttempts(),\n (testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.worstTestStepResult.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n }\n )\n const features = _.map(groupedTestCaseAttempts, (group, uri) => {\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && !doesHaveValue(testStep.pickleStepId)\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinExampleRuleMap: Record<string, messages.Rule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (doesHaveValue(testStep.pickleStepId)) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = {\n status: messages.TestStepResultStatus[status].toLowerCase(),\n }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration =\n messages.TimeConversion.durationToMilliseconds(\n testStepResult.duration\n ) * 1000000\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (_.size(testStepAttachments) > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return _.map(feature.tags, (tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinScenarioMap: Record<string, messages.Scenario>\n }): IJsonTag[] {\n const scenario = gherkinScenarioMap[pickle.astNodeIds[0]]\n\n return pickle.tags.map(\n (tagData: messages.PickleTag): IJsonTag =>\n this.getScenarioTag(tagData, feature, scenario)\n )\n }\n\n private getScenarioTag(\n tagData: messages.PickleTag,\n feature: messages.Feature,\n scenario: messages.Scenario\n ): IJsonTag {\n const byAstNodeId = (tag: messages.Tag): Boolean =>\n tag.id === tagData.astNodeId\n const flatten = (\n acc: messages.Tag[],\n val: messages.Tag[]\n ): messages.Tag[] => acc.concat(val)\n\n const tag =\n feature.tags.find(byAstNodeId) ||\n scenario.tags.find(byAstNodeId) ||\n scenario.examples\n .map((e) => e.tags)\n .reduce(flatten, [])\n .find(byAstNodeId)\n\n return {\n name: tagData.name,\n line: tag?.location?.line,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names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GherkinDocumentParser, PickleParser } from './helpers'\nimport * as messages from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst { getScenarioDescription, getPickleStepMap, getStepKeyword } =\n PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.Feature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.Feature\n gherkinScenarioMap: Record<string, messages.Scenario>\n gherkinExampleRuleMap: Record<string, messages.Rule>\n gherkinScenarioLocationMap: Record<string, messages.Location>\n pickle: messages.Pickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n public static readonly documentation: string =\n 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/cucumber/tree/master/json-formatter).'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: messages.Feature | messages.Pickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({\n cells: row.cells.map((x) => x.value),\n })),\n }\n }\n\n formatDocString(\n docString: messages.PickleDocString,\n gherkinStep: messages.Step\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.PickleStepArgument,\n gherkinStep: messages.Step\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n this.eventDataCollector\n .getTestCaseAttempts()\n .forEach((testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n })\n const features = Object.keys(groupedTestCaseAttempts).map((uri) => {\n const group = groupedTestCaseAttempts[uri]\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && !doesHaveValue(testStep.pickleStepId)\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinExampleRuleMap: Record<string, messages.Rule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (doesHaveValue(testStep.pickleStepId)) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = {\n status: messages.TestStepResultStatus[status].toLowerCase(),\n }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration =\n messages.TimeConversion.durationToMilliseconds(\n testStepResult.duration\n ) * 1000000\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (testStepAttachments?.length > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return feature.tags.map((tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinScenarioMap: Record<string, messages.Scenario>\n }): IJsonTag[] {\n const scenario = gherkinScenarioMap[pickle.astNodeIds[0]]\n\n return pickle.tags.map(\n (tagData: messages.PickleTag): IJsonTag =>\n this.getScenarioTag(tagData, feature, scenario)\n )\n }\n\n private getScenarioTag(\n tagData: messages.PickleTag,\n feature: messages.Feature,\n scenario: messages.Scenario\n ): IJsonTag {\n const byAstNodeId = (tag: messages.Tag): Boolean =>\n tag.id === tagData.astNodeId\n const flatten = (\n acc: messages.Tag[],\n val: messages.Tag[]\n ): messages.Tag[] => acc.concat(val)\n\n const tag =\n feature.tags.find(byAstNodeId) ||\n scenario.tags.find(byAstNodeId) ||\n scenario.examples\n .map((e) => e.tags)\n .reduce(flatten, [])\n .find(byAstNodeId)\n\n return {\n name: tagData.name,\n line: tag?.location?.line,\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import Formatter, { IFormatterOptions } from '.';
2
2
  export default class MessageFormatter extends Formatter {
3
+ static readonly documentation: string;
3
4
  constructor(options: IFormatterOptions);
4
5
  }
@@ -11,4 +11,5 @@ class MessageFormatter extends _1.default {
11
11
  }
12
12
  }
13
13
  exports.default = MessageFormatter;
14
+ MessageFormatter.documentation = 'Outputs protobuf messages';
14
15
  //# sourceMappingURL=message_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;IACrD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAC1C,CAAA;IACH,CAAC;CACF;AAPD,mCAOC","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\n\nexport default class MessageFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope) + '\\n')\n )\n }\n}\n"]}
1
+ {"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;IAErD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAC1C,CAAA;IACH,CAAC;;AAPH,mCAQC;AAPwB,8BAAa,GAAW,2BAA2B,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\n\nexport default class MessageFormatter extends Formatter {\n public static readonly documentation: string = 'Outputs protobuf messages'\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope) + '\\n')\n )\n }\n}\n"]}
@@ -6,6 +6,7 @@ export default class ProgressBarFormatter extends Formatter {
6
6
  private testRunStarted;
7
7
  private issueCount;
8
8
  progressBar: ProgressBar;
9
+ static readonly documentation: string;
9
10
  constructor(options: IFormatterOptions);
10
11
  incrementStepCount(pickleId: string): void;
11
12
  initializeProgressBar(): void;
@@ -22,7 +22,7 @@ class ProgressBarFormatter extends _1.default {
22
22
  this.numberOfSteps += pickle.steps.length;
23
23
  }
24
24
  initializeProgressBar() {
25
- if (value_checker_1.doesHaveValue(this.progressBar)) {
25
+ if ((0, value_checker_1.doesHaveValue)(this.progressBar)) {
26
26
  return;
27
27
  }
28
28
  this.progressBar = new progress_1.default(':current/:total steps [:bar] ', {
@@ -30,25 +30,25 @@ class ProgressBarFormatter extends _1.default {
30
30
  incomplete: ' ',
31
31
  stream: this.stream,
32
32
  total: this.numberOfSteps,
33
- width: value_checker_1.valueOrDefault(this.stream.columns, 80),
33
+ width: (0, value_checker_1.valueOrDefault)(this.stream.columns, 80),
34
34
  });
35
35
  }
36
36
  logProgress({ testStepId, testCaseStartedId, }) {
37
37
  const { testCase } = this.eventDataCollector.getTestCaseAttempt(testCaseStartedId);
38
38
  const testStep = testCase.testSteps.find((s) => s.id === testStepId);
39
- if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
39
+ if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
40
40
  this.progressBar.tick();
41
41
  }
42
42
  }
43
43
  logUndefinedParametertype(parameterType) {
44
- this.log(`Undefined parameter type: ${issue_helpers_1.formatUndefinedParameterType(parameterType)}\n`);
44
+ this.log(`Undefined parameter type: ${(0, issue_helpers_1.formatUndefinedParameterType)(parameterType)}\n`);
45
45
  }
46
46
  logErrorIfNeeded(testCaseFinished) {
47
47
  const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
48
- if (helpers_1.isIssue(worstTestStepResult)) {
48
+ if ((0, helpers_1.isIssue)(worstTestStepResult)) {
49
49
  this.issueCount += 1;
50
50
  const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
51
- this.progressBar.interrupt(helpers_1.formatIssue({
51
+ this.progressBar.interrupt((0, helpers_1.formatIssue)({
52
52
  colorFns: this.colorFns,
53
53
  cwd: this.cwd,
54
54
  number: this.issueCount,
@@ -56,43 +56,44 @@ class ProgressBarFormatter extends _1.default {
56
56
  supportCodeLibrary: this.supportCodeLibrary,
57
57
  testCaseAttempt,
58
58
  }));
59
- if (worstTestStepResult.willBeRetried) {
59
+ if (testCaseFinished.willBeRetried) {
60
60
  const stepsToRetry = testCaseAttempt.pickle.steps.length;
61
61
  this.progressBar.tick(-stepsToRetry);
62
62
  }
63
63
  }
64
64
  }
65
65
  logSummary(testRunFinished) {
66
- const testRunDuration = time_1.durationBetweenTimestamps(this.testRunStarted.timestamp, testRunFinished.timestamp);
67
- this.log(helpers_1.formatSummary({
66
+ const testRunDuration = (0, time_1.durationBetweenTimestamps)(this.testRunStarted.timestamp, testRunFinished.timestamp);
67
+ this.log((0, helpers_1.formatSummary)({
68
68
  colorFns: this.colorFns,
69
69
  testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),
70
70
  testRunDuration,
71
71
  }));
72
72
  }
73
73
  parseEnvelope(envelope) {
74
- if (value_checker_1.doesHaveValue(envelope.undefinedParameterType)) {
74
+ if ((0, value_checker_1.doesHaveValue)(envelope.undefinedParameterType)) {
75
75
  this.logUndefinedParametertype(envelope.undefinedParameterType);
76
76
  }
77
- else if (value_checker_1.doesHaveValue(envelope.testCase)) {
77
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testCase)) {
78
78
  this.incrementStepCount(envelope.testCase.pickleId);
79
79
  }
80
- else if (value_checker_1.doesHaveValue(envelope.testStepStarted)) {
80
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testStepStarted)) {
81
81
  this.initializeProgressBar();
82
82
  }
83
- else if (value_checker_1.doesHaveValue(envelope.testStepFinished)) {
83
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testStepFinished)) {
84
84
  this.logProgress(envelope.testStepFinished);
85
85
  }
86
- else if (value_checker_1.doesHaveValue(envelope.testCaseFinished)) {
86
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
87
87
  this.logErrorIfNeeded(envelope.testCaseFinished);
88
88
  }
89
- else if (value_checker_1.doesHaveValue(envelope.testRunStarted)) {
89
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testRunStarted)) {
90
90
  this.testRunStarted = envelope.testRunStarted;
91
91
  }
92
- else if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
92
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
93
93
  this.logSummary(envelope.testRunFinished);
94
94
  }
95
95
  }
96
96
  }
97
97
  exports.default = ProgressBarFormatter;
98
+ ProgressBarFormatter.documentation = 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run';
98
99
  //# sourceMappingURL=progress_bar_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA+D;AAC/D,0CAAiD;AACjD,wDAAkC;AAGlC,oDAAgE;AAChE,2DAAsE;AACtE,kCAAmD;AAEnD,qGAAqG;AACrG,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACtE,IAAI,CAAC,aAAa,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAA;IACrB,CAAC;IAED,kBAAkB,CAAC,QAAgB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC1D,IAAI,CAAC,aAAa,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAA;IAC3C,CAAC;IAED,qBAAqB;QACnB,IAAI,6BAAa,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YACnC,OAAM;SACP;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAW,CAAC,+BAA+B,EAAE;YAClE,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,GAAG;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,aAAa;YACzB,KAAK,EAAE,8BAAc,CAAE,IAAI,CAAC,MAAyB,CAAC,OAAO,EAAE,EAAE,CAAC;SACnE,CAAC,CAAA;IACJ,CAAC;IAED,WAAW,CAAC,EACV,UAAU,EACV,iBAAiB,GACS;QA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U,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;SAC1C;IACH,CAAC;CACF;AA9GD,uCA8GC","sourcesContent":["import { formatIssue, formatSummary, isIssue } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport ProgressBar from 'progress'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { formatUndefinedParameterType } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\n\n// Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber\nexport default class ProgressBarFormatter extends Formatter {\n private numberOfSteps: number\n private testRunStarted: messages.TestRunStarted\n private issueCount: number\n public progressBar: ProgressBar\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n this.numberOfSteps = 0\n this.issueCount = 0\n }\n\n incrementStepCount(pickleId: string): void {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n this.numberOfSteps += pickle.steps.length\n }\n\n initializeProgressBar(): void {\n if (doesHaveValue(this.progressBar)) {\n return\n }\n this.progressBar = new ProgressBar(':current/:total steps [:bar] ', {\n clear: true,\n incomplete: ' ',\n stream: this.stream,\n total: this.numberOfSteps,\n width: valueOrDefault((this.stream as TtyWriteStream).columns, 80),\n })\n }\n\n logProgress({\n testStepId,\n testCaseStartedId,\n }: messages.TestStepFinished): void {\n const { testCase } =\n this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)\n const testStep = testCase.testSteps.find((s) => s.id === testStepId)\n if (doesHaveValue(testStep.pickleStepId)) {\n this.progressBar.tick()\n }\n }\n\n logUndefinedParametertype(\n parameterType: messages.UndefinedParameterType\n ): void {\n this.log(\n `Undefined parameter type: ${formatUndefinedParameterType(\n parameterType\n )}\\n`\n )\n }\n\n logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (isIssue(worstTestStepResult)) {\n this.issueCount += 1\n const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n this.progressBar.interrupt(\n formatIssue({\n colorFns: this.colorFns,\n cwd: this.cwd,\n number: this.issueCount,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n )\n if (worstTestStepResult.willBeRetried) {\n const stepsToRetry = testCaseAttempt.pickle.steps.length\n this.progressBar.tick(-stepsToRetry)\n }\n }\n }\n\n logSummary(testRunFinished: messages.TestRunFinished): void {\n const testRunDuration = durationBetweenTimestamps(\n this.testRunStarted.timestamp,\n testRunFinished.timestamp\n )\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),\n testRunDuration,\n })\n )\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.undefinedParameterType)) {\n this.logUndefinedParametertype(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.incrementStepCount(envelope.testCase.pickleId)\n } else if (doesHaveValue(envelope.testStepStarted)) {\n this.initializeProgressBar()\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.logErrorIfNeeded(envelope.testCaseFinished)\n } else if (doesHaveValue(envelope.testRunStarted)) {\n this.testRunStarted = envelope.testRunStarted\n } else if (doesHaveValue(envelope.testRunFinished)) {\n this.logSummary(envelope.testRunFinished)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;AAAA,uCAA+D;AAC/D,0CAAiD;AACjD,wDAAkC;AAGlC,oDAAgE;AAChE,2DAAsE;AACtE,kCAAmD;AAEnD,qGAAqG;AACrG,MAAqB,oB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E,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE;YAC/D,eAAe;SAChB,CAAC,CACH,CAAA;IACH,CAAC;IAED,aAAa,CAAC,QAA2B;QACvC,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE;YAClD,IAAI,CAAC,yBAAyB,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAA;SAChE;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC3C,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;SACpD;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAClD,IAAI,CAAC,qBAAqB,EAAE,CAAA;SAC7B;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;SAC5C;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;SACjD;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,cAAc,CAAC,EAAE;YACjD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAA;SAC9C;aAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;SAC1C;IACH,CAAC;;AA/GH,uCAgHC;AA3GwB,kCAAa,GAClC,qJAAqJ,CAAA","sourcesContent":["import { formatIssue, formatSummary, isIssue } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport ProgressBar from 'progress'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { formatUndefinedParameterType } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\n\n// Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber\nexport default class ProgressBarFormatter extends Formatter {\n private numberOfSteps: number\n private testRunStarted: messages.TestRunStarted\n private issueCount: number\n public progressBar: ProgressBar\n public static readonly documentation: string =\n 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n this.numberOfSteps = 0\n this.issueCount = 0\n }\n\n incrementStepCount(pickleId: string): void {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n this.numberOfSteps += pickle.steps.length\n }\n\n initializeProgressBar(): void {\n if (doesHaveValue(this.progressBar)) {\n return\n }\n this.progressBar = new ProgressBar(':current/:total steps [:bar] ', {\n clear: true,\n incomplete: ' ',\n stream: this.stream,\n total: this.numberOfSteps,\n width: valueOrDefault((this.stream as TtyWriteStream).columns, 80),\n })\n }\n\n logProgress({\n testStepId,\n testCaseStartedId,\n }: messages.TestStepFinished): void {\n const { testCase } =\n this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)\n const testStep = testCase.testSteps.find((s) => s.id === testStepId)\n if (doesHaveValue(testStep.pickleStepId)) {\n this.progressBar.tick()\n }\n }\n\n logUndefinedParametertype(\n parameterType: messages.UndefinedParameterType\n ): void {\n this.log(\n `Undefined parameter type: ${formatUndefinedParameterType(\n parameterType\n )}\\n`\n )\n }\n\n logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (isIssue(worstTestStepResult)) {\n this.issueCount += 1\n const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n this.progressBar.interrupt(\n formatIssue({\n colorFns: this.colorFns,\n cwd: this.cwd,\n number: this.issueCount,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n )\n if (testCaseFinished.willBeRetried) {\n const stepsToRetry = testCaseAttempt.pickle.steps.length\n this.progressBar.tick(-stepsToRetry)\n }\n }\n }\n\n logSummary(testRunFinished: messages.TestRunFinished): void {\n const testRunDuration = durationBetweenTimestamps(\n this.testRunStarted.timestamp,\n testRunFinished.timestamp\n )\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),\n testRunDuration,\n })\n )\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.undefinedParameterType)) {\n this.logUndefinedParametertype(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.incrementStepCount(envelope.testCase.pickleId)\n } else if (doesHaveValue(envelope.testStepStarted)) {\n this.initializeProgressBar()\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.logErrorIfNeeded(envelope.testCaseFinished)\n } else if (doesHaveValue(envelope.testRunStarted)) {\n this.testRunStarted = envelope.testRunStarted\n } else if (doesHaveValue(envelope.testRunFinished)) {\n this.logSummary(envelope.testRunFinished)\n }\n }\n}\n"]}
@@ -3,6 +3,7 @@ import { IFormatterOptions } from './index';
3
3
  import * as messages from '@cucumber/messages';
4
4
  import ITestStepFinished = messages.TestStepFinished;
5
5
  export default class ProgressFormatter extends SummaryFormatter {
6
+ static readonly documentation: string;
6
7
  constructor(options: IFormatterOptions);
7
8
  logProgress({ testStepResult: { status } }: ITestStepFinished): void;
8
9
  }
@@ -36,10 +36,10 @@ const STATUS_CHARACTER_MAPPING = new Map([
36
36
  class ProgressFormatter extends summary_formatter_1.default {
37
37
  constructor(options) {
38
38
  options.eventBroadcaster.on('envelope', (envelope) => {
39
- if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
39
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
40
40
  this.log('\n\n');
41
41
  }
42
- else if (value_checker_1.doesHaveValue(envelope.testStepFinished)) {
42
+ else if ((0, value_checker_1.doesHaveValue)(envelope.testStepFinished)) {
43
43
  this.logProgress(envelope.testStepFinished);
44
44
  }
45
45
  });
@@ -51,4 +51,5 @@ class ProgressFormatter extends summary_formatter_1.default {
51
51
  }
52
52
  }
53
53
  exports.default = ProgressFormatter;
54
+ ProgressFormatter.documentation = 'Prints one character per scenario.';
54
55
  //# sourceMappingURL=progress_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEhD,6DAA8C;AAI9C,MAAM,wBAAwB,GAC5B,IAAI,GAAG,CAAC;IACN,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;IAC9C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEJ,MAAqB,iBAAkB,SAAQ,2BAAgB;IAC7D,YAAY,OAA0B;QACpC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,6BAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;aACjB;iBAAM,IAAI,6BAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;gBACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;aAC5C;QACH,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,WAAW,CAAC,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,EAAqB;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAC/C,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CACrC,CAAA;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrB,CAAC;CACF;AAlBD,oCAkBC","sourcesContent":["import SummaryFormatter from './summary_formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { IFormatterOptions } from './index'\nimport * as messages from '@cucumber/messages'\nimport IEnvelope = messages.Envelope\nimport ITestStepFinished = messages.TestStepFinished\n\nconst STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =\n new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, 'A'],\n [messages.TestStepResultStatus.FAILED, 'F'],\n [messages.TestStepResultStatus.PASSED, '.'],\n [messages.TestStepResultStatus.PENDING, 'P'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, 'U'],\n ])\n\nexport default class ProgressFormatter extends SummaryFormatter {\n constructor(options: IFormatterOptions) {\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.log('\\n\\n')\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n }\n })\n super(options)\n }\n\n logProgress({ testStepResult: { status } }: ITestStepFinished): void {\n const character = this.colorFns.forStatus(status)(\n STATUS_CHARACTER_MAPPING.get(status)\n )\n this.log(character)\n }\n}\n"]}
1
+ {"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEhD,6DAA8C;AAI9C,MAAM,wBAAwB,GAC5B,IAAI,GAAG,CAAC;IACN,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;IAC9C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEJ,MAAqB,iBAAkB,SAAQ,2BAAgB;IAI7D,YAAY,OAA0B;QACpC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;aACjB;iBAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;gBACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;aAC5C;QACH,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,WAAW,CAAC,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,EAAqB;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAC/C,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CACrC,CAAA;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrB,CAAC;;AApBH,oCAqBC;AApBwB,+BAAa,GAClC,oCAAoC,CAAA","sourcesContent":["import SummaryFormatter from './summary_formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { IFormatterOptions } from './index'\nimport * as messages from '@cucumber/messages'\nimport IEnvelope = messages.Envelope\nimport ITestStepFinished = messages.TestStepFinished\n\nconst STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =\n new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, 'A'],\n [messages.TestStepResultStatus.FAILED, 'F'],\n [messages.TestStepResultStatus.PASSED, '.'],\n [messages.TestStepResultStatus.PENDING, 'P'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, 'U'],\n ])\n\nexport default class ProgressFormatter extends SummaryFormatter {\n public static readonly documentation: string =\n 'Prints one character per scenario.'\n\n constructor(options: IFormatterOptions) {\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.log('\\n\\n')\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n }\n })\n super(options)\n }\n\n logProgress({ testStepResult: { status } }: ITestStepFinished): void {\n const character = this.colorFns.forStatus(status)(\n STATUS_CHARACTER_MAPPING.get(status)\n )\n this.log(character)\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_CUCUMBER_PUBLISH_URL = "https://messages.cucumber.io/api/reports";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CUCUMBER_PUBLISH_URL = void 0;
4
+ exports.DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
5
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/formatter/publish.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GACvC,0CAA0C,CAAA","sourcesContent":["export const DEFAULT_CUCUMBER_PUBLISH_URL =\n 'https://messages.cucumber.io/api/reports'\n"]}
@@ -1,6 +1,7 @@
1
1
  import Formatter, { IFormatterOptions } from './';
2
2
  export default class RerunFormatter extends Formatter {
3
3
  private readonly separator;
4
+ static readonly documentation: string;
4
5
  constructor(options: IFormatterOptions);
5
6
  logFailedTestCases(): void;
6
7
  }
@@ -22,7 +22,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- const lodash_1 = __importDefault(require("lodash"));
26
25
  const _1 = __importDefault(require("./"));
27
26
  const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
28
27
  const value_checker_1 = require("../value_checker");
@@ -32,31 +31,36 @@ class RerunFormatter extends _1.default {
32
31
  constructor(options) {
33
32
  super(options);
34
33
  options.eventBroadcaster.on('envelope', (envelope) => {
35
- if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
34
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
36
35
  this.logFailedTestCases();
37
36
  }
38
37
  });
39
- const rerunOptions = value_checker_1.valueOrDefault(options.parsedArgvOptions.rerun, {});
40
- this.separator = value_checker_1.valueOrDefault(rerunOptions.separator, DEFAULT_SEPARATOR);
38
+ const rerunOptions = (0, value_checker_1.valueOrDefault)(options.parsedArgvOptions.rerun, {});
39
+ this.separator = (0, value_checker_1.valueOrDefault)(rerunOptions.separator, DEFAULT_SEPARATOR);
41
40
  }
42
41
  logFailedTestCases() {
43
42
  const mapping = {};
44
- lodash_1.default.each(this.eventDataCollector.getTestCaseAttempts(), ({ gherkinDocument, pickle, worstTestStepResult }) => {
43
+ this.eventDataCollector
44
+ .getTestCaseAttempts()
45
+ .forEach(({ gherkinDocument, pickle, worstTestStepResult }) => {
45
46
  if (worstTestStepResult.status !== messages.TestStepResultStatus.PASSED) {
46
47
  const relativeUri = pickle.uri;
47
- const line = gherkin_document_parser_1.getGherkinScenarioLocationMap(gherkinDocument)[lodash_1.default.last(pickle.astNodeIds)].line;
48
- if (value_checker_1.doesNotHaveValue(mapping[relativeUri])) {
48
+ const line = (0, gherkin_document_parser_1.getGherkinScenarioLocationMap)(gherkinDocument)[pickle.astNodeIds[pickle.astNodeIds.length - 1]].line;
49
+ if ((0, value_checker_1.doesNotHaveValue)(mapping[relativeUri])) {
49
50
  mapping[relativeUri] = [];
50
51
  }
51
52
  mapping[relativeUri].push(line);
52
53
  }
53
54
  });
54
- const text = lodash_1.default.chain(mapping)
55
- .map((lines, uri) => `${uri}:${lines.join(':')}`)
56
- .join(this.separator)
57
- .value();
55
+ const text = Object.keys(mapping)
56
+ .map((uri) => {
57
+ const lines = mapping[uri];
58
+ return `${uri}:${lines.join(':')}`;
59
+ })
60
+ .join(this.separator);
58
61
  this.log(text);
59
62
  }
60
63
  }
61
64
  exports.default = RerunFormatter;
65
+ RerunFormatter.documentation = 'Prints failing files with line numbers.';
62
66
  //# sourceMappingURL=rerun_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rerun_formatter.js","sourceRoot":"","sources":["../../src/formatter/rerun_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,0CAAiD;AACjD,+EAAiF;AACjF,oDAIyB;AACzB,6DAA8C;AAE9C,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAM9B,MAAqB,cAAe,SAAQ,UAAS;IAGnD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,6BAAa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I,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;CACF;AAxCD,iCAwCC","sourcesContent":["import _ from 'lodash'\nimport Formatter, { IFormatterOptions } from './'\nimport { getGherkinScenarioLocationMap } from './helpers/gherkin_document_parser'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\nimport * as messages from '@cucumber/messages'\n\nconst DEFAULT_SEPARATOR = '\\n'\n\ninterface UriToLinesMap {\n [uri: string]: number[]\n}\n\nexport default class RerunFormatter extends Formatter {\n private readonly separator: string\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logFailedTestCases()\n }\n })\n const rerunOptions = valueOrDefault(options.parsedArgvOptions.rerun, {})\n this.separator = valueOrDefault(rerunOptions.separator, DEFAULT_SEPARATOR)\n }\n\n logFailedTestCases(): void {\n const mapping: UriToLinesMap = {}\n _.each(\n this.eventDataCollector.getTestCaseAttempts(),\n ({ gherkinDocument, pickle, worstTestStepResult }) => {\n if (\n worstTestStepResult.status !== messages.TestStepResultStatus.PASSED\n ) {\n const relativeUri = pickle.uri\n const line =\n getGherkinScenarioLocationMap(gherkinDocument)[\n _.last(pickle.astNodeIds)\n ].line\n if (doesNotHaveValue(mapping[relativeUri])) {\n mapping[relativeUri] = []\n }\n mapping[relativeUri].push(line)\n }\n }\n )\n const text = _.chain(mapping)\n .map((lines, uri) => `${uri}:${lines.join(':')}`)\n .join(this.separator)\n .value()\n this.log(text)\n }\n}\n"]}
1
+ {"version":3,"file":"rerun_formatter.js","sourceRoot":"","sources":["../../src/formatter/rerun_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,+EAAiF;AACjF,oDAIyB;AACzB,6DAA8C;AAE9C,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAM9B,MAAqB,cAAe,SAAQ,UAAS;IAK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G,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;YAC1B,OAAO,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QACpC,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACvB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,CAAC;;AA1CH,iCA2CC;AAzCwB,4BAAa,GAClC,yCAAyC,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { getGherkinScenarioLocationMap } from './helpers/gherkin_document_parser'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\nimport * as messages from '@cucumber/messages'\n\nconst DEFAULT_SEPARATOR = '\\n'\n\ninterface UriToLinesMap {\n [uri: string]: number[]\n}\n\nexport default class RerunFormatter extends Formatter {\n private readonly separator: string\n public static readonly documentation: string =\n 'Prints failing files with line numbers.'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logFailedTestCases()\n }\n })\n const rerunOptions = valueOrDefault(options.parsedArgvOptions.rerun, {})\n this.separator = valueOrDefault(rerunOptions.separator, DEFAULT_SEPARATOR)\n }\n\n logFailedTestCases(): void {\n const mapping: UriToLinesMap = {}\n this.eventDataCollector\n .getTestCaseAttempts()\n .forEach(({ gherkinDocument, pickle, worstTestStepResult }) => {\n if (\n worstTestStepResult.status !== messages.TestStepResultStatus.PASSED\n ) {\n const relativeUri = pickle.uri\n const line =\n getGherkinScenarioLocationMap(gherkinDocument)[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].line\n if (doesNotHaveValue(mapping[relativeUri])) {\n mapping[relativeUri] = []\n }\n mapping[relativeUri].push(line)\n }\n })\n const text = Object.keys(mapping)\n .map((uri) => {\n const lines = mapping[uri]\n return `${uri}:${lines.join(':')}`\n })\n .join(this.separator)\n this.log(text)\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import Formatter, { IFormatterOptions } from './';
2
2
  export default class SnippetsFormatter extends Formatter {
3
+ static readonly documentation: string;
3
4
  constructor(options: IFormatterOptions);
4
5
  logSnippets(): void;
5
6
  }
@@ -30,7 +30,7 @@ class SnippetsFormatter extends _1.default {
30
30
  constructor(options) {
31
31
  super(options);
32
32
  options.eventBroadcaster.on('envelope', (envelope) => {
33
- if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
33
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
34
34
  this.logSnippets();
35
35
  }
36
36
  });
@@ -38,7 +38,7 @@ class SnippetsFormatter extends _1.default {
38
38
  logSnippets() {
39
39
  const snippets = [];
40
40
  this.eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {
41
- const parsed = helpers_1.parseTestCaseAttempt({
41
+ const parsed = (0, helpers_1.parseTestCaseAttempt)({
42
42
  cwd: this.cwd,
43
43
  snippetBuilder: this.snippetBuilder,
44
44
  supportCodeLibrary: this.supportCodeLibrary,
@@ -54,4 +54,5 @@ class SnippetsFormatter extends _1.default {
54
54
  }
55
55
  }
56
56
  exports.default = SnippetsFormatter;
57
+ SnippetsFormatter.documentation = "The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps";
57
58
  //# sourceMappingURL=snippets_formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAAgD;AAChD,oDAAgD;AAChD,6DAA8C;AAG9C,MAAqB,iBAAkB,SAAQ,UAAS;IACtD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,6BAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,8BAAoB,CAAC;gBAClC,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;aAChB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,IACE,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAClE;oBACA,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,CAAC;CACF;AA7BD,oCA6BC","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { parseTestCaseAttempt } from './helpers'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\nimport IEnvelope = messages.Envelope\n\nexport default class SnippetsFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logSnippets()\n }\n })\n }\n\n logSnippets(): void {\n const snippets: string[] = []\n this.eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {\n const parsed = parseTestCaseAttempt({\n cwd: this.cwd,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n parsed.testSteps.forEach((testStep) => {\n if (\n testStep.result.status === messages.TestStepResultStatus.UNDEFINED\n ) {\n snippets.push(testStep.snippet)\n }\n })\n })\n this.log(snippets.join('\\n\\n'))\n }\n}\n"]}
1
+ {"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAAgD;AAChD,oDAAgD;AAChD,6DAA8C;AAG9C,MAAqB,iBAAkB,SAAQ,UAAS;IAItD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC;gBAClC,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;aAChB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,IACE,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAClE;oBACA,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,CAAC;;AA/BH,oCAgCC;AA/BwB,+BAAa,GAClC,iIAAiI,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { parseTestCaseAttempt } from './helpers'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\nimport IEnvelope = messages.Envelope\n\nexport default class SnippetsFormatter extends Formatter {\n public static readonly documentation: string =\n \"The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps\"\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logSnippets()\n }\n })\n }\n\n logSnippets(): void {\n const snippets: string[] = []\n this.eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {\n const parsed = parseTestCaseAttempt({\n cwd: this.cwd,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n parsed.testSteps.forEach((testStep) => {\n if (\n testStep.result.status === messages.TestStepResultStatus.UNDEFINED\n ) {\n snippets.push(testStep.snippet)\n }\n })\n })\n this.log(snippets.join('\\n\\n'))\n }\n}\n"]}
@@ -32,8 +32,8 @@ class StepDefinitionSnippetBuilder {
32
32
  }
33
33
  }
34
34
  getStepParameterNames(step) {
35
- if (value_checker_1.doesHaveValue(step.argument)) {
36
- const argumentName = step_arguments_1.parseStepArgument(step.argument, {
35
+ if ((0, value_checker_1.doesHaveValue)(step.argument)) {
36
+ const argumentName = (0, step_arguments_1.parseStepArgument)(step.argument, {
37
37
  dataTable: () => 'dataTable',
38
38
  docString: () => 'docString',
39
39
  });