@dev-blinq/cucumber-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +124 -0
  3. package/api/index.d.ts +6 -0
  4. package/bin/cucumber-js +3 -0
  5. package/bin/cucumber.js +3 -0
  6. package/lib/api/console_logger.d.ts +12 -0
  7. package/lib/api/console_logger.js +24 -0
  8. package/lib/api/console_logger.js.map +1 -0
  9. package/lib/api/convert_configuration.d.ts +4 -0
  10. package/lib/api/convert_configuration.js +65 -0
  11. package/lib/api/convert_configuration.js.map +1 -0
  12. package/lib/api/environment.d.ts +2 -0
  13. package/lib/api/environment.js +14 -0
  14. package/lib/api/environment.js.map +1 -0
  15. package/lib/api/formatters.d.ts +20 -0
  16. package/lib/api/formatters.js +61 -0
  17. package/lib/api/formatters.js.map +1 -0
  18. package/lib/api/gherkin.d.ts +21 -0
  19. package/lib/api/gherkin.js +65 -0
  20. package/lib/api/gherkin.js.map +1 -0
  21. package/lib/api/index.d.ts +12 -0
  22. package/lib/api/index.js +28 -0
  23. package/lib/api/index.js.map +1 -0
  24. package/lib/api/load_configuration.d.ts +9 -0
  25. package/lib/api/load_configuration.js +41 -0
  26. package/lib/api/load_configuration.js.map +1 -0
  27. package/lib/api/load_sources.d.ts +9 -0
  28. package/lib/api/load_sources.js +53 -0
  29. package/lib/api/load_sources.js.map +1 -0
  30. package/lib/api/load_support.d.ts +10 -0
  31. package/lib/api/load_support.js +30 -0
  32. package/lib/api/load_support.js.map +1 -0
  33. package/lib/api/paths.d.ts +8 -0
  34. package/lib/api/paths.js +102 -0
  35. package/lib/api/paths.js.map +1 -0
  36. package/lib/api/plugins.d.ts +4 -0
  37. package/lib/api/plugins.js +19 -0
  38. package/lib/api/plugins.js.map +1 -0
  39. package/lib/api/run_cucumber.d.ts +11 -0
  40. package/lib/api/run_cucumber.js +115 -0
  41. package/lib/api/run_cucumber.js.map +1 -0
  42. package/lib/api/runtime.d.ts +21 -0
  43. package/lib/api/runtime.js +36 -0
  44. package/lib/api/runtime.js.map +1 -0
  45. package/lib/api/support.d.ts +9 -0
  46. package/lib/api/support.js +26 -0
  47. package/lib/api/support.js.map +1 -0
  48. package/lib/api/test_helpers.d.ts +3 -0
  49. package/lib/api/test_helpers.js +36 -0
  50. package/lib/api/test_helpers.js.map +1 -0
  51. package/lib/api/types.d.ts +175 -0
  52. package/lib/api/types.js +3 -0
  53. package/lib/api/types.js.map +1 -0
  54. package/lib/api/wrapper.mjs +6 -0
  55. package/lib/cli/helpers.d.ts +37 -0
  56. package/lib/cli/helpers.js +203 -0
  57. package/lib/cli/helpers.js.map +1 -0
  58. package/lib/cli/i18n.d.ts +2 -0
  59. package/lib/cli/i18n.js +70 -0
  60. package/lib/cli/i18n.js.map +1 -0
  61. package/lib/cli/index.d.ts +21 -0
  62. package/lib/cli/index.js +59 -0
  63. package/lib/cli/index.js.map +1 -0
  64. package/lib/cli/install_validator.d.ts +1 -0
  65. package/lib/cli/install_validator.js +18 -0
  66. package/lib/cli/install_validator.js.map +1 -0
  67. package/lib/cli/run.d.ts +1 -0
  68. package/lib/cli/run.js +44 -0
  69. package/lib/cli/run.js.map +1 -0
  70. package/lib/cli/validate_node_engine_version.d.ts +10 -0
  71. package/lib/cli/validate_node_engine_version.js +24 -0
  72. package/lib/cli/validate_node_engine_version.js.map +1 -0
  73. package/lib/configuration/argv_parser.d.ts +20 -0
  74. package/lib/configuration/argv_parser.js +102 -0
  75. package/lib/configuration/argv_parser.js.map +1 -0
  76. package/lib/configuration/check_schema.d.ts +2 -0
  77. package/lib/configuration/check_schema.js +60 -0
  78. package/lib/configuration/check_schema.js.map +1 -0
  79. package/lib/configuration/default_configuration.d.ts +2 -0
  80. package/lib/configuration/default_configuration.js +27 -0
  81. package/lib/configuration/default_configuration.js.map +1 -0
  82. package/lib/configuration/from_file.d.ts +3 -0
  83. package/lib/configuration/from_file.js +85 -0
  84. package/lib/configuration/from_file.js.map +1 -0
  85. package/lib/configuration/helpers.d.ts +1 -0
  86. package/lib/configuration/helpers.js +11 -0
  87. package/lib/configuration/helpers.js.map +1 -0
  88. package/lib/configuration/index.d.ts +7 -0
  89. package/lib/configuration/index.js +29 -0
  90. package/lib/configuration/index.js.map +1 -0
  91. package/lib/configuration/locate_file.d.ts +1 -0
  92. package/lib/configuration/locate_file.js +21 -0
  93. package/lib/configuration/locate_file.js.map +1 -0
  94. package/lib/configuration/merge_configurations.d.ts +2 -0
  95. package/lib/configuration/merge_configurations.js +48 -0
  96. package/lib/configuration/merge_configurations.js.map +1 -0
  97. package/lib/configuration/option_splitter.d.ts +3 -0
  98. package/lib/configuration/option_splitter.js +23 -0
  99. package/lib/configuration/option_splitter.js.map +1 -0
  100. package/lib/configuration/types.d.ts +28 -0
  101. package/lib/configuration/types.js +3 -0
  102. package/lib/configuration/types.js.map +1 -0
  103. package/lib/configuration/validate_configuration.d.ts +3 -0
  104. package/lib/configuration/validate_configuration.js +13 -0
  105. package/lib/configuration/validate_configuration.js.map +1 -0
  106. package/lib/filter_stack_trace.d.ts +3 -0
  107. package/lib/filter_stack_trace.js +38 -0
  108. package/lib/filter_stack_trace.js.map +1 -0
  109. package/lib/formatter/builder.d.ts +37 -0
  110. package/lib/formatter/builder.js +101 -0
  111. package/lib/formatter/builder.js.map +1 -0
  112. package/lib/formatter/fixtures/typescript.d.ts +2 -0
  113. package/lib/formatter/fixtures/typescript.js +6 -0
  114. package/lib/formatter/fixtures/typescript.js.map +1 -0
  115. package/lib/formatter/get_color_fns.d.ts +15 -0
  116. package/lib/formatter/get_color_fns.js +56 -0
  117. package/lib/formatter/get_color_fns.js.map +1 -0
  118. package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
  119. package/lib/formatter/helpers/duration_helpers.js +9 -0
  120. package/lib/formatter/helpers/duration_helpers.js.map +1 -0
  121. package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
  122. package/lib/formatter/helpers/event_data_collector.js +126 -0
  123. package/lib/formatter/helpers/event_data_collector.js.map +1 -0
  124. package/lib/formatter/helpers/formatters.d.ts +6 -0
  125. package/lib/formatter/helpers/formatters.js +43 -0
  126. package/lib/formatter/helpers/formatters.js.map +1 -0
  127. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
  128. package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
  129. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
  130. package/lib/formatter/helpers/index.d.ts +10 -0
  131. package/lib/formatter/helpers/index.js +52 -0
  132. package/lib/formatter/helpers/index.js.map +1 -0
  133. package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
  134. package/lib/formatter/helpers/issue_helpers.js +59 -0
  135. package/lib/formatter/helpers/issue_helpers.js.map +1 -0
  136. package/lib/formatter/helpers/keyword_type.d.ts +11 -0
  137. package/lib/formatter/helpers/keyword_type.js +32 -0
  138. package/lib/formatter/helpers/keyword_type.js.map +1 -0
  139. package/lib/formatter/helpers/location_helpers.d.ts +2 -0
  140. package/lib/formatter/helpers/location_helpers.js +17 -0
  141. package/lib/formatter/helpers/location_helpers.js.map +1 -0
  142. package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
  143. package/lib/formatter/helpers/pickle_parser.js +28 -0
  144. package/lib/formatter/helpers/pickle_parser.js.map +1 -0
  145. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
  146. package/lib/formatter/helpers/step_argument_formatter.js +48 -0
  147. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
  148. package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
  149. package/lib/formatter/helpers/summary_helpers.js +96 -0
  150. package/lib/formatter/helpers/summary_helpers.js.map +1 -0
  151. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
  152. package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
  153. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
  154. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
  155. package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
  156. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
  157. package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
  158. package/lib/formatter/helpers/usage_helpers/index.js +111 -0
  159. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
  160. package/lib/formatter/html_formatter.d.ts +7 -0
  161. package/lib/formatter/html_formatter.js +30 -0
  162. package/lib/formatter/html_formatter.js.map +1 -0
  163. package/lib/formatter/index.d.ts +53 -0
  164. package/lib/formatter/index.js +21 -0
  165. package/lib/formatter/index.js.map +1 -0
  166. package/lib/formatter/json_formatter.d.ts +78 -0
  167. package/lib/formatter/json_formatter.js +230 -0
  168. package/lib/formatter/json_formatter.js.map +1 -0
  169. package/lib/formatter/junit_formatter.d.ts +17 -0
  170. package/lib/formatter/junit_formatter.js +181 -0
  171. package/lib/formatter/junit_formatter.js.map +1 -0
  172. package/lib/formatter/message_formatter.d.ts +5 -0
  173. package/lib/formatter/message_formatter.js +15 -0
  174. package/lib/formatter/message_formatter.js.map +1 -0
  175. package/lib/formatter/progress_bar_formatter.d.ts +18 -0
  176. package/lib/formatter/progress_bar_formatter.js +99 -0
  177. package/lib/formatter/progress_bar_formatter.js.map +1 -0
  178. package/lib/formatter/progress_formatter.d.ts +9 -0
  179. package/lib/formatter/progress_formatter.js +59 -0
  180. package/lib/formatter/progress_formatter.js.map +1 -0
  181. package/lib/formatter/rerun_formatter.d.ts +13 -0
  182. package/lib/formatter/rerun_formatter.js +80 -0
  183. package/lib/formatter/rerun_formatter.js.map +1 -0
  184. package/lib/formatter/snippets_formatter.d.ts +6 -0
  185. package/lib/formatter/snippets_formatter.js +61 -0
  186. package/lib/formatter/snippets_formatter.js.map +1 -0
  187. package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
  188. package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
  189. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
  190. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
  191. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
  192. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
  193. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
  194. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
  195. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
  196. package/lib/formatter/summary_formatter.d.ts +14 -0
  197. package/lib/formatter/summary_formatter.js +68 -0
  198. package/lib/formatter/summary_formatter.js.map +1 -0
  199. package/lib/formatter/usage_formatter.d.ts +6 -0
  200. package/lib/formatter/usage_formatter.js +98 -0
  201. package/lib/formatter/usage_formatter.js.map +1 -0
  202. package/lib/formatter/usage_json_formatter.d.ts +7 -0
  203. package/lib/formatter/usage_json_formatter.js +34 -0
  204. package/lib/formatter/usage_json_formatter.js.map +1 -0
  205. package/lib/importer.js +13 -0
  206. package/lib/index.d.ts +58 -0
  207. package/lib/index.js +109 -0
  208. package/lib/index.js.map +1 -0
  209. package/lib/logger.d.ts +5 -0
  210. package/lib/logger.js +3 -0
  211. package/lib/logger.js.map +1 -0
  212. package/lib/models/data_table.d.ts +10 -0
  213. package/lib/models/data_table.js +46 -0
  214. package/lib/models/data_table.js.map +1 -0
  215. package/lib/models/definition.d.ts +55 -0
  216. package/lib/models/definition.js +22 -0
  217. package/lib/models/definition.js.map +1 -0
  218. package/lib/models/gherkin_step_keyword.d.ts +1 -0
  219. package/lib/models/gherkin_step_keyword.js +3 -0
  220. package/lib/models/gherkin_step_keyword.js.map +1 -0
  221. package/lib/models/pickle_order.d.ts +1 -0
  222. package/lib/models/pickle_order.js +3 -0
  223. package/lib/models/pickle_order.js.map +1 -0
  224. package/lib/models/step_definition.d.ts +11 -0
  225. package/lib/models/step_definition.js +37 -0
  226. package/lib/models/step_definition.js.map +1 -0
  227. package/lib/models/test_case_hook_definition.d.ts +10 -0
  228. package/lib/models/test_case_hook_definition.js +27 -0
  229. package/lib/models/test_case_hook_definition.js.map +1 -0
  230. package/lib/models/test_run_hook_definition.d.ts +3 -0
  231. package/lib/models/test_run_hook_definition.js +10 -0
  232. package/lib/models/test_run_hook_definition.js.map +1 -0
  233. package/lib/models/test_step_hook_definition.d.ts +9 -0
  234. package/lib/models/test_step_hook_definition.js +26 -0
  235. package/lib/models/test_step_hook_definition.js.map +1 -0
  236. package/lib/pickle_filter.d.ts +42 -0
  237. package/lib/pickle_filter.js +99 -0
  238. package/lib/pickle_filter.js.map +1 -0
  239. package/lib/plugin/index.d.ts +2 -0
  240. package/lib/plugin/index.js +19 -0
  241. package/lib/plugin/index.js.map +1 -0
  242. package/lib/plugin/plugin_manager.d.ts +13 -0
  243. package/lib/plugin/plugin_manager.js +36 -0
  244. package/lib/plugin/plugin_manager.js.map +1 -0
  245. package/lib/plugin/types.d.ts +14 -0
  246. package/lib/plugin/types.js +3 -0
  247. package/lib/plugin/types.js.map +1 -0
  248. package/lib/publish/http_stream.d.ts +30 -0
  249. package/lib/publish/http_stream.js +112 -0
  250. package/lib/publish/http_stream.js.map +1 -0
  251. package/lib/publish/index.d.ts +2 -0
  252. package/lib/publish/index.js +5 -0
  253. package/lib/publish/index.js.map +1 -0
  254. package/lib/publish/publish_plugin.d.ts +2 -0
  255. package/lib/publish/publish_plugin.js +48 -0
  256. package/lib/publish/publish_plugin.js.map +1 -0
  257. package/lib/runtime/assemble_test_cases.d.ts +13 -0
  258. package/lib/runtime/assemble_test_cases.js +88 -0
  259. package/lib/runtime/assemble_test_cases.js.map +1 -0
  260. package/lib/runtime/attachment_manager/index.d.ts +33 -0
  261. package/lib/runtime/attachment_manager/index.js +119 -0
  262. package/lib/runtime/attachment_manager/index.js.map +1 -0
  263. package/lib/runtime/format_error.d.ts +2 -0
  264. package/lib/runtime/format_error.js +36 -0
  265. package/lib/runtime/format_error.js.map +1 -0
  266. package/lib/runtime/helpers.d.ts +6 -0
  267. package/lib/runtime/helpers.js +101 -0
  268. package/lib/runtime/helpers.js.map +1 -0
  269. package/lib/runtime/index.d.ts +40 -0
  270. package/lib/runtime/index.js +76 -0
  271. package/lib/runtime/index.js.map +1 -0
  272. package/lib/runtime/parallel/command_types.d.ts +32 -0
  273. package/lib/runtime/parallel/command_types.js +3 -0
  274. package/lib/runtime/parallel/command_types.js.map +1 -0
  275. package/lib/runtime/parallel/coordinator.d.ts +72 -0
  276. package/lib/runtime/parallel/coordinator.js +222 -0
  277. package/lib/runtime/parallel/coordinator.js.map +1 -0
  278. package/lib/runtime/parallel/run_worker.d.ts +1 -0
  279. package/lib/runtime/parallel/run_worker.js +29 -0
  280. package/lib/runtime/parallel/run_worker.js.map +1 -0
  281. package/lib/runtime/parallel/worker.d.ts +26 -0
  282. package/lib/runtime/parallel/worker.js +87 -0
  283. package/lib/runtime/parallel/worker.js.map +1 -0
  284. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  285. package/lib/runtime/run_test_run_hooks.js +28 -0
  286. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  287. package/lib/runtime/step_runner.d.ts +16 -0
  288. package/lib/runtime/step_runner.js +88 -0
  289. package/lib/runtime/step_runner.js.map +1 -0
  290. package/lib/runtime/stopwatch.d.ts +12 -0
  291. package/lib/runtime/stopwatch.js +34 -0
  292. package/lib/runtime/stopwatch.js.map +1 -0
  293. package/lib/runtime/test_case_runner.d.ts +54 -0
  294. package/lib/runtime/test_case_runner.js +268 -0
  295. package/lib/runtime/test_case_runner.js.map +1 -0
  296. package/lib/step_arguments.d.ts +6 -0
  297. package/lib/step_arguments.js +19 -0
  298. package/lib/step_arguments.js.map +1 -0
  299. package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
  300. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  301. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  302. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  303. package/lib/support_code_library_builder/get_definition_line_and_uri.js +29 -0
  304. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  305. package/lib/support_code_library_builder/index.d.ts +74 -0
  306. package/lib/support_code_library_builder/index.js +304 -0
  307. package/lib/support_code_library_builder/index.js.map +1 -0
  308. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  309. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  310. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  311. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -0
  312. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
  313. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
  314. package/lib/support_code_library_builder/types.d.ts +88 -0
  315. package/lib/support_code_library_builder/types.js +3 -0
  316. package/lib/support_code_library_builder/types.js.map +1 -0
  317. package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
  318. package/lib/support_code_library_builder/validate_arguments.js +73 -0
  319. package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
  320. package/lib/support_code_library_builder/world.d.ts +18 -0
  321. package/lib/support_code_library_builder/world.js +11 -0
  322. package/lib/support_code_library_builder/world.js.map +1 -0
  323. package/lib/time.d.ts +18 -0
  324. package/lib/time.js +61 -0
  325. package/lib/time.js.map +1 -0
  326. package/lib/try_require.d.ts +7 -0
  327. package/lib/try_require.js +26 -0
  328. package/lib/try_require.js.map +1 -0
  329. package/lib/types/index.d.ts +4 -0
  330. package/lib/types/index.js +3 -0
  331. package/lib/types/index.js.map +1 -0
  332. package/lib/uncaught_exception_manager.d.ts +7 -0
  333. package/lib/uncaught_exception_manager.js +12 -0
  334. package/lib/uncaught_exception_manager.js.map +1 -0
  335. package/lib/user_code_runner.d.ts +14 -0
  336. package/lib/user_code_runner.js +82 -0
  337. package/lib/user_code_runner.js.map +1 -0
  338. package/lib/value_checker.d.ts +3 -0
  339. package/lib/value_checker.js +19 -0
  340. package/lib/value_checker.js.map +1 -0
  341. package/lib/version.d.ts +1 -0
  342. package/lib/version.js +6 -0
  343. package/lib/version.js.map +1 -0
  344. package/lib/wrapper.mjs +44 -0
  345. package/package.json +189 -0
@@ -0,0 +1,78 @@
1
+ import Formatter, { IFormatterOptions } from './';
2
+ import * as messages from '@cucumber/messages';
3
+ export interface IJsonFeature {
4
+ description: string;
5
+ elements: IJsonScenario[];
6
+ id: string;
7
+ keyword: string;
8
+ line: number;
9
+ name: string;
10
+ tags: IJsonTag[];
11
+ uri: string;
12
+ }
13
+ export interface IJsonScenario {
14
+ description: string;
15
+ id: string;
16
+ keyword: string;
17
+ line: number;
18
+ name: string;
19
+ steps: IJsonStep[];
20
+ tags: IJsonTag[];
21
+ type: string;
22
+ }
23
+ export interface IJsonStep {
24
+ arguments?: any;
25
+ embeddings?: any;
26
+ hidden?: boolean;
27
+ keyword?: string;
28
+ line?: number;
29
+ match?: any;
30
+ name?: string;
31
+ result?: any;
32
+ }
33
+ export interface IJsonTag {
34
+ name: string;
35
+ line: number;
36
+ }
37
+ interface IBuildJsonFeatureOptions {
38
+ feature: messages.Feature;
39
+ elements: IJsonScenario[];
40
+ uri: string;
41
+ }
42
+ interface IBuildJsonScenarioOptions {
43
+ feature: messages.Feature;
44
+ gherkinScenarioMap: Record<string, messages.Scenario>;
45
+ gherkinExampleRuleMap: Record<string, messages.Rule>;
46
+ gherkinScenarioLocationMap: Record<string, messages.Location>;
47
+ pickle: messages.Pickle;
48
+ steps: IJsonStep[];
49
+ }
50
+ interface IBuildJsonStepOptions {
51
+ isBeforeHook: boolean;
52
+ gherkinStepMap: Record<string, messages.Step>;
53
+ pickleStepMap: Record<string, messages.PickleStep>;
54
+ testStep: messages.TestStep;
55
+ testStepAttachments: messages.Attachment[];
56
+ testStepResult: messages.TestStepResult;
57
+ }
58
+ export default class JsonFormatter extends Formatter {
59
+ static readonly documentation: string;
60
+ constructor(options: IFormatterOptions);
61
+ convertNameToId(obj: messages.Feature | messages.Pickle): string;
62
+ formatDataTable(dataTable: messages.PickleTable): any;
63
+ formatDocString(docString: messages.PickleDocString, gherkinStep: messages.Step): any;
64
+ formatStepArgument(stepArgument: messages.PickleStepArgument, gherkinStep: messages.Step): any;
65
+ onTestRunFinished(): void;
66
+ getFeatureData({ feature, elements, uri, }: IBuildJsonFeatureOptions): IJsonFeature;
67
+ getScenarioData({ feature, gherkinScenarioLocationMap, gherkinExampleRuleMap, gherkinScenarioMap, pickle, steps, }: IBuildJsonScenarioOptions): IJsonScenario;
68
+ private formatScenarioId;
69
+ getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }: IBuildJsonStepOptions): IJsonStep;
70
+ getFeatureTags(feature: messages.Feature): IJsonTag[];
71
+ getScenarioTags({ feature, pickle, gherkinScenarioMap, }: {
72
+ feature: messages.Feature;
73
+ pickle: messages.Pickle;
74
+ gherkinScenarioMap: Record<string, messages.Scenario>;
75
+ }): IJsonTag[];
76
+ private getScenarioTag;
77
+ }
78
+ export {};
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const _1 = __importDefault(require("./"));
30
+ const helpers_1 = require("./helpers");
31
+ const messages = __importStar(require("@cucumber/messages"));
32
+ const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
33
+ const value_checker_1 = require("../value_checker");
34
+ const step_arguments_1 = require("../step_arguments");
35
+ const duration_helpers_1 = require("./helpers/duration_helpers");
36
+ const { getGherkinStepMap, getGherkinScenarioMap } = helpers_1.GherkinDocumentParser;
37
+ const { getScenarioDescription, getPickleStepMap, getStepKeyword } = helpers_1.PickleParser;
38
+ class JsonFormatter extends _1.default {
39
+ constructor(options) {
40
+ super(options);
41
+ options.eventBroadcaster.on('envelope', (envelope) => {
42
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
43
+ this.onTestRunFinished();
44
+ }
45
+ });
46
+ }
47
+ convertNameToId(obj) {
48
+ return obj.name.replace(/ /g, '-').toLowerCase();
49
+ }
50
+ formatDataTable(dataTable) {
51
+ return {
52
+ rows: dataTable.rows.map((row) => ({
53
+ cells: row.cells.map((x) => x.value),
54
+ })),
55
+ };
56
+ }
57
+ formatDocString(docString, gherkinStep) {
58
+ return {
59
+ content: docString.content,
60
+ line: gherkinStep.docString.location.line,
61
+ };
62
+ }
63
+ formatStepArgument(stepArgument, gherkinStep) {
64
+ if ((0, value_checker_1.doesNotHaveValue)(stepArgument)) {
65
+ return [];
66
+ }
67
+ return [
68
+ (0, step_arguments_1.parseStepArgument)(stepArgument, {
69
+ dataTable: (dataTable) => this.formatDataTable(dataTable),
70
+ docString: (docString) => this.formatDocString(docString, gherkinStep),
71
+ }),
72
+ ];
73
+ }
74
+ onTestRunFinished() {
75
+ const groupedTestCaseAttempts = {};
76
+ this.eventDataCollector
77
+ .getTestCaseAttempts()
78
+ .forEach((testCaseAttempt) => {
79
+ if (!testCaseAttempt.willBeRetried) {
80
+ const uri = testCaseAttempt.pickle.uri;
81
+ if ((0, value_checker_1.doesNotHaveValue)(groupedTestCaseAttempts[uri])) {
82
+ groupedTestCaseAttempts[uri] = [];
83
+ }
84
+ groupedTestCaseAttempts[uri].push(testCaseAttempt);
85
+ }
86
+ });
87
+ const features = Object.keys(groupedTestCaseAttempts).map((uri) => {
88
+ const group = groupedTestCaseAttempts[uri];
89
+ const { gherkinDocument } = group[0];
90
+ const gherkinStepMap = getGherkinStepMap(gherkinDocument);
91
+ const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument);
92
+ const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
93
+ const gherkinScenarioLocationMap = (0, gherkin_document_parser_1.getGherkinScenarioLocationMap)(gherkinDocument);
94
+ const elements = group.map((testCaseAttempt) => {
95
+ const { pickle } = testCaseAttempt;
96
+ const pickleStepMap = getPickleStepMap(pickle);
97
+ let isBeforeHook = true;
98
+ const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {
99
+ isBeforeHook = isBeforeHook && !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
100
+ return this.getStepData({
101
+ isBeforeHook,
102
+ gherkinStepMap,
103
+ pickleStepMap,
104
+ testStep,
105
+ testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],
106
+ testStepResult: testCaseAttempt.stepResults[testStep.id],
107
+ });
108
+ });
109
+ return this.getScenarioData({
110
+ feature: gherkinDocument.feature,
111
+ gherkinScenarioLocationMap,
112
+ gherkinExampleRuleMap,
113
+ gherkinScenarioMap,
114
+ pickle,
115
+ steps,
116
+ });
117
+ });
118
+ return this.getFeatureData({
119
+ feature: gherkinDocument.feature,
120
+ elements,
121
+ uri,
122
+ });
123
+ });
124
+ this.log(JSON.stringify(features, null, 2));
125
+ }
126
+ getFeatureData({ feature, elements, uri, }) {
127
+ return {
128
+ description: feature.description,
129
+ elements,
130
+ id: this.convertNameToId(feature),
131
+ line: feature.location.line,
132
+ keyword: feature.keyword,
133
+ name: feature.name,
134
+ tags: this.getFeatureTags(feature),
135
+ uri,
136
+ };
137
+ }
138
+ getScenarioData({ feature, gherkinScenarioLocationMap, gherkinExampleRuleMap, gherkinScenarioMap, pickle, steps, }) {
139
+ const description = getScenarioDescription({
140
+ pickle,
141
+ gherkinScenarioMap,
142
+ });
143
+ return {
144
+ description,
145
+ id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),
146
+ keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,
147
+ line: gherkinScenarioLocationMap[pickle.astNodeIds[pickle.astNodeIds.length - 1]].line,
148
+ name: pickle.name,
149
+ steps,
150
+ tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),
151
+ type: 'scenario',
152
+ };
153
+ }
154
+ formatScenarioId({ feature, pickle, gherkinExampleRuleMap, }) {
155
+ let parts;
156
+ const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
157
+ if ((0, value_checker_1.doesHaveValue)(rule)) {
158
+ parts = [feature, rule, pickle];
159
+ }
160
+ else {
161
+ parts = [feature, pickle];
162
+ }
163
+ return parts.map((part) => this.convertNameToId(part)).join(';');
164
+ }
165
+ getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
166
+ const data = {};
167
+ if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
168
+ const pickleStep = pickleStepMap[testStep.pickleStepId];
169
+ data.arguments = this.formatStepArgument(pickleStep.argument, gherkinStepMap[pickleStep.astNodeIds[0]]);
170
+ data.keyword = getStepKeyword({ pickleStep, gherkinStepMap });
171
+ data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
172
+ data.name = pickleStep.text;
173
+ }
174
+ else {
175
+ data.keyword = isBeforeHook ? 'Before' : 'After';
176
+ data.hidden = true;
177
+ }
178
+ if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) &&
179
+ testStep.stepDefinitionIds.length === 1) {
180
+ const stepDefinition = this.supportCodeLibrary.stepDefinitions.find((s) => s.id === testStep.stepDefinitionIds[0]);
181
+ data.match = { location: (0, helpers_1.formatLocation)(stepDefinition) };
182
+ }
183
+ const { message, status } = testStepResult;
184
+ data.result = {
185
+ status: messages.TestStepResultStatus[status].toLowerCase(),
186
+ };
187
+ if ((0, value_checker_1.doesHaveValue)(testStepResult.duration)) {
188
+ data.result.duration = (0, duration_helpers_1.durationToNanoseconds)(testStepResult.duration);
189
+ }
190
+ if (status === messages.TestStepResultStatus.FAILED &&
191
+ (0, value_checker_1.doesHaveValue)(message)) {
192
+ data.result.error_message = message;
193
+ }
194
+ if ((testStepAttachments === null || testStepAttachments === void 0 ? void 0 : testStepAttachments.length) > 0) {
195
+ data.embeddings = testStepAttachments.map((attachment) => ({
196
+ data: attachment.body,
197
+ mime_type: attachment.mediaType,
198
+ }));
199
+ }
200
+ return data;
201
+ }
202
+ getFeatureTags(feature) {
203
+ return feature.tags.map((tagData) => ({
204
+ name: tagData.name,
205
+ line: tagData.location.line,
206
+ }));
207
+ }
208
+ getScenarioTags({ feature, pickle, gherkinScenarioMap, }) {
209
+ const scenario = gherkinScenarioMap[pickle.astNodeIds[0]];
210
+ return pickle.tags.map((tagData) => this.getScenarioTag(tagData, feature, scenario));
211
+ }
212
+ getScenarioTag(tagData, feature, scenario) {
213
+ var _a;
214
+ const byAstNodeId = (tag) => tag.id === tagData.astNodeId;
215
+ const flatten = (acc, val) => acc.concat(val);
216
+ const tag = feature.tags.find(byAstNodeId) ||
217
+ scenario.tags.find(byAstNodeId) ||
218
+ scenario.examples
219
+ .map((e) => e.tags)
220
+ .reduce(flatten, [])
221
+ .find(byAstNodeId);
222
+ return {
223
+ name: tagData.name,
224
+ line: (_a = tag === null || tag === void 0 ? void 0 : tag.location) === null || _a === void 0 ? void 0 : _a.line,
225
+ };
226
+ }
227
+ }
228
+ exports.default = JsonFormatter;
229
+ 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/json-formatter).';
230
+ //# sourceMappingURL=json_formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAA+E;AAC/E,6DAA8C;AAC9C,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AACrD,iEAAkE;AAElE,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+BAAqB,CAAA;AAE1E,MAAM,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAChE,sBAAY,CAAA;AAoEd,MAAqB,aAAc,SAAQ,UAAS;IAIlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,GAAuC;QACrD,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAClD,CAAC;IAED,eAAe,CAAC,SAA+B;QAC7C,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBACjC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;aACrC,CAAC,CAAC;SACJ,CAAA;IACH,CAAC;I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AAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,IAAI;SAC1B,CAAA;IACH,CAAC;;AA3QH,gCA4QC;AA3QwB,2BAAa,GAClC,kMAAkM,CAAA","sourcesContent":["import 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'\nimport { durationToNanoseconds } from './helpers/duration_helpers'\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/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[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].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 = durationToNanoseconds(testStepResult.duration)\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"]}
@@ -0,0 +1,17 @@
1
+ import Formatter, { IFormatterOptions } from './';
2
+ export default class JunitFormatter extends Formatter {
3
+ private readonly names;
4
+ private readonly suiteName;
5
+ static readonly documentation: string;
6
+ constructor(options: IFormatterOptions);
7
+ private getTestCases;
8
+ private getTestSteps;
9
+ private getTestStep;
10
+ private getTestCaseResult;
11
+ private durationToSeconds;
12
+ private nameOrDefault;
13
+ private getTestCaseName;
14
+ private formatTestSteps;
15
+ private onTestRunFinished;
16
+ private buildXmlReport;
17
+ }
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const xmlbuilder_1 = __importDefault(require("xmlbuilder"));
7
+ const _1 = __importDefault(require("./"));
8
+ const messages_1 = require("@cucumber/messages");
9
+ const value_checker_1 = require("../value_checker");
10
+ const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
11
+ const pickle_parser_1 = require("./helpers/pickle_parser");
12
+ const value_checker_2 = require("../value_checker");
13
+ class JunitFormatter extends _1.default {
14
+ constructor(options) {
15
+ var _a;
16
+ super(options);
17
+ this.names = {};
18
+ this.suiteName = (0, value_checker_2.valueOrDefault)((_a = options.parsedArgvOptions.junit) === null || _a === void 0 ? void 0 : _a.suiteName, 'cucumber-js');
19
+ options.eventBroadcaster.on('envelope', (envelope) => {
20
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
21
+ this.onTestRunFinished();
22
+ }
23
+ });
24
+ }
25
+ getTestCases() {
26
+ return this.eventDataCollector
27
+ .getTestCaseAttempts()
28
+ .filter((attempt) => !attempt.willBeRetried);
29
+ }
30
+ getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap) {
31
+ return testCaseAttempt.testCase.testSteps.map((testStep) => {
32
+ const isBeforeHook = !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
33
+ return this.getTestStep({
34
+ isBeforeHook,
35
+ gherkinStepMap,
36
+ pickleStepMap,
37
+ testStep,
38
+ testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],
39
+ testStepResult: testCaseAttempt.stepResults[testStep.id],
40
+ });
41
+ });
42
+ }
43
+ getTestStep({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
44
+ const data = {};
45
+ if (testStep.pickleStepId) {
46
+ const pickleStep = pickleStepMap[testStep.pickleStepId];
47
+ data.keyword = (0, pickle_parser_1.getStepKeyword)({ pickleStep, gherkinStepMap });
48
+ data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
49
+ data.name = pickleStep.text;
50
+ }
51
+ else {
52
+ data.keyword = isBeforeHook ? 'Before' : 'After';
53
+ data.hidden = true;
54
+ }
55
+ data.result = testStepResult;
56
+ data.time = testStepResult.duration
57
+ ? this.durationToSeconds(testStepResult.duration)
58
+ : 0;
59
+ data.attachments = testStepAttachments;
60
+ return data;
61
+ }
62
+ getTestCaseResult(steps) {
63
+ const { status, message, exception } = (0, messages_1.getWorstTestStepResult)(steps.map((step) => step.result));
64
+ return {
65
+ status,
66
+ failure: message || exception
67
+ ? {
68
+ type: exception === null || exception === void 0 ? void 0 : exception.type,
69
+ message: exception === null || exception === void 0 ? void 0 : exception.message,
70
+ detail: message,
71
+ }
72
+ : undefined,
73
+ };
74
+ }
75
+ durationToSeconds(duration) {
76
+ const NANOS_IN_SECOND = 1000000000;
77
+ return ((duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND);
78
+ }
79
+ nameOrDefault(name, fallbackSuffix) {
80
+ if (!name) {
81
+ return `(unnamed ${fallbackSuffix})`;
82
+ }
83
+ return name;
84
+ }
85
+ getTestCaseName(feature, rule, pickle) {
86
+ const featureName = this.nameOrDefault(feature.name, 'feature');
87
+ const pickleName = this.nameOrDefault(pickle.name, 'scenario');
88
+ const testCaseName = rule
89
+ ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName
90
+ : pickleName;
91
+ if (!this.names[featureName]) {
92
+ this.names[featureName] = [];
93
+ }
94
+ let index = 0;
95
+ while (this.names[featureName].includes(index > 0 ? `${testCaseName} [${index}]` : testCaseName)) {
96
+ index++;
97
+ }
98
+ const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName;
99
+ this.names[featureName].push(name);
100
+ return name;
101
+ }
102
+ formatTestSteps(steps) {
103
+ return steps
104
+ .filter((step) => !step.hidden)
105
+ .map((step) => {
106
+ const statusText = step.result.status.toLowerCase();
107
+ const maxLength = 80 - statusText.length - 3;
108
+ const stepText = `${step.keyword}${step.name}`
109
+ .padEnd(maxLength, '.')
110
+ .substring(0, maxLength);
111
+ return `${stepText}...${statusText}`;
112
+ })
113
+ .join('\n');
114
+ }
115
+ onTestRunFinished() {
116
+ const testCases = this.getTestCases();
117
+ const tests = testCases.map((testCaseAttempt) => {
118
+ const { gherkinDocument, pickle } = testCaseAttempt;
119
+ const { feature } = gherkinDocument;
120
+ const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
121
+ const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
122
+ const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(gherkinDocument);
123
+ const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(pickle);
124
+ const steps = this.getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap);
125
+ const stepDuration = steps.reduce((total, step) => total + (step.time || 0), 0);
126
+ return {
127
+ classname: this.nameOrDefault(feature.name, 'feature'),
128
+ name: this.getTestCaseName(feature, rule, pickle),
129
+ time: stepDuration,
130
+ result: this.getTestCaseResult(steps),
131
+ systemOutput: this.formatTestSteps(steps),
132
+ steps,
133
+ };
134
+ });
135
+ const passed = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.PASSED).length;
136
+ const skipped = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.SKIPPED).length;
137
+ const failures = tests.length - passed - skipped;
138
+ const testSuite = {
139
+ name: this.suiteName,
140
+ tests,
141
+ failures,
142
+ skipped,
143
+ time: tests.reduce((total, test) => total + test.time, 0),
144
+ };
145
+ this.log(this.buildXmlReport(testSuite));
146
+ }
147
+ buildXmlReport(testSuite) {
148
+ const xmlReport = xmlbuilder_1.default
149
+ .create('testsuite', { invalidCharReplacement: '' })
150
+ .att('failures', testSuite.failures)
151
+ .att('skipped', testSuite.skipped)
152
+ .att('name', testSuite.name)
153
+ .att('time', testSuite.time)
154
+ .att('tests', testSuite.tests.length);
155
+ testSuite.tests.forEach((test) => {
156
+ var _a, _b, _c;
157
+ const xmlTestCase = xmlReport.ele('testcase', {
158
+ classname: test.classname,
159
+ name: test.name,
160
+ time: test.time,
161
+ });
162
+ if (test.result.status === messages_1.TestStepResultStatus.SKIPPED) {
163
+ xmlTestCase.ele('skipped');
164
+ }
165
+ else if (test.result.status !== messages_1.TestStepResultStatus.PASSED) {
166
+ const xmlFailure = xmlTestCase.ele('failure', {
167
+ type: (_a = test.result.failure) === null || _a === void 0 ? void 0 : _a.type,
168
+ message: (_b = test.result.failure) === null || _b === void 0 ? void 0 : _b.message,
169
+ });
170
+ if ((_c = test.result) === null || _c === void 0 ? void 0 : _c.failure) {
171
+ xmlFailure.cdata(test.result.failure.detail);
172
+ }
173
+ }
174
+ xmlTestCase.ele('system-out', {}).cdata(test.systemOutput);
175
+ });
176
+ return xmlReport.end({ pretty: true });
177
+ }
178
+ }
179
+ exports.default = JunitFormatter;
180
+ JunitFormatter.documentation = 'Outputs JUnit report';
181
+ //# sourceMappingURL=junit_formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junit_formatter.js","sourceRoot":"","sources":["../../src/formatter/junit_formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AACnC,0CAAiD;AAEjD,iDAS2B;AAE3B,oDAAgD;AAChD,+EAG0C;AAC1C,2DAA0E;AAC1E,oDAAiD;AAiDjD,MAAqB,cAAe,SAAQ,UAAS;IAKnD,YAAY,OAA0B;;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QALC,UAAK,GAA6B,EAAE,CAAA;QAMnD,IAAI,CAAC,SAAS,GAAG,IAAA,8BAAc,EAC7B,MAAA,OAAO,CAAC,iBAAiB,CAAC,KAAK,0CAAE,SAAS,EAC1C,aAAa,CACd,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,kBAAkB;aAC3B,mBAAmB,EAAE;aACrB,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC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AC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;YAC/B,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE;gBAC5C,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAA;YACF,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,+BAAoB,CAAC,OAAO,EAAE;gBACvD,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;aAC3B;iBAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,+BAAoB,CAAC,MAAM,EAAE;gBAC7D,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE;oBAC5C,IAAI,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,0CAAE,IAAI;oBAC/B,OAAO,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,0CAAE,OAAO;iBACtC,CAAC,CAAA;gBACF,IAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,EAAE;oBACxB,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;iBAC7C;aACF;YACD,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;;AA5NH,iCA6NC;AA1NwB,4BAAa,GAAW,sBAAsB,CAAA","sourcesContent":["import xmlbuilder from 'xmlbuilder'\nimport Formatter, { IFormatterOptions } from './'\nimport * as messages from '@cucumber/messages'\nimport {\n Attachment,\n Duration,\n Feature,\n getWorstTestStepResult,\n Pickle,\n Rule,\n TestStepResult,\n TestStepResultStatus,\n} from '@cucumber/messages'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue } from '../value_checker'\nimport {\n getGherkinExampleRuleMap,\n getGherkinStepMap,\n} from './helpers/gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './helpers/pickle_parser'\nimport { valueOrDefault } from '../value_checker'\n\ninterface IJUnitTestSuite {\n name: string\n failures: number\n skipped: number\n time: number\n tests: IJUnitTestCase[]\n}\n\ninterface IJUnitTestCase {\n classname: string\n name: string\n time: number\n result: IJUnitTestCaseResult\n systemOutput: string\n steps: IJUnitTestStep[]\n}\n\ninterface IJUnitTestCaseFailure {\n type: string\n message?: string\n detail: string\n}\n\ninterface IJUnitTestCaseResult {\n status: TestStepResultStatus\n failure?: IJUnitTestCaseFailure\n}\n\ninterface IJUnitTestStep {\n attachments: Attachment[]\n hidden: boolean\n keyword: string\n line: number\n name?: string\n result: TestStepResult\n time: number\n}\n\ninterface IBuildJUnitTestStepOptions {\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\nexport default class JunitFormatter extends Formatter {\n private readonly names: Record<string, string[]> = {}\n private readonly suiteName: string\n public static readonly documentation: string = 'Outputs JUnit report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.suiteName = valueOrDefault(\n options.parsedArgvOptions.junit?.suiteName,\n 'cucumber-js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n private getTestCases() {\n return this.eventDataCollector\n .getTestCaseAttempts()\n .filter((attempt) => !attempt.willBeRetried)\n }\n\n private getTestSteps(\n testCaseAttempt: ITestCaseAttempt,\n gherkinStepMap: Record<string, messages.Step>,\n pickleStepMap: Record<string, messages.PickleStep>\n ) {\n return testCaseAttempt.testCase.testSteps.map((testStep) => {\n const isBeforeHook = !doesHaveValue(testStep.pickleStepId)\n return this.getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n }\n\n private getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJUnitTestStepOptions): IJUnitTestStep {\n const data: Partial<IJUnitTestStep> = {}\n if (testStep.pickleStepId) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\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 data.result = testStepResult\n data.time = testStepResult.duration\n ? this.durationToSeconds(testStepResult.duration)\n : 0\n data.attachments = testStepAttachments\n return data as IJUnitTestStep\n }\n\n private getTestCaseResult(steps: IJUnitTestStep[]): IJUnitTestCaseResult {\n const { status, message, exception } = getWorstTestStepResult(\n steps.map((step) => step.result)\n )\n return {\n status,\n failure:\n message || exception\n ? {\n type: exception?.type,\n message: exception?.message,\n detail: message,\n }\n : undefined,\n }\n }\n\n private durationToSeconds(duration: Duration): number {\n const NANOS_IN_SECOND = 1_000_000_000\n return (\n (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND\n )\n }\n\n private nameOrDefault(name: string, fallbackSuffix: string): string {\n if (!name) {\n return `(unnamed ${fallbackSuffix})`\n }\n return name\n }\n\n private getTestCaseName(\n feature: Feature,\n rule: Rule | undefined,\n pickle: Pickle\n ) {\n const featureName = this.nameOrDefault(feature.name, 'feature')\n const pickleName = this.nameOrDefault(pickle.name, 'scenario')\n const testCaseName = rule\n ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName\n : pickleName\n if (!this.names[featureName]) {\n this.names[featureName] = []\n }\n let index = 0\n while (\n this.names[featureName].includes(\n index > 0 ? `${testCaseName} [${index}]` : testCaseName\n )\n ) {\n index++\n }\n const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName\n this.names[featureName].push(name)\n return name\n }\n\n private formatTestSteps(steps: IJUnitTestStep[]): string {\n return steps\n .filter((step) => !step.hidden)\n .map((step) => {\n const statusText = step.result.status.toLowerCase()\n const maxLength = 80 - statusText.length - 3\n const stepText = `${step.keyword}${step.name}`\n .padEnd(maxLength, '.')\n .substring(0, maxLength)\n return `${stepText}...${statusText}`\n })\n .join('\\n')\n }\n\n private onTestRunFinished(): void {\n const testCases = this.getTestCases()\n\n const tests = testCases.map<IJUnitTestCase>(\n (testCaseAttempt: ITestCaseAttempt) => {\n const { gherkinDocument, pickle } = testCaseAttempt\n const { feature } = gherkinDocument\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n\n const steps = this.getTestSteps(\n testCaseAttempt,\n gherkinStepMap,\n pickleStepMap\n )\n const stepDuration = steps.reduce(\n (total, step) => total + (step.time || 0),\n 0\n )\n\n return {\n classname: this.nameOrDefault(feature.name, 'feature'),\n name: this.getTestCaseName(feature, rule, pickle),\n time: stepDuration,\n result: this.getTestCaseResult(steps),\n systemOutput: this.formatTestSteps(steps),\n steps,\n }\n }\n )\n\n const passed = tests.filter(\n (item) => item.result.status === TestStepResultStatus.PASSED\n ).length\n const skipped = tests.filter(\n (item) => item.result.status === TestStepResultStatus.SKIPPED\n ).length\n const failures = tests.length - passed - skipped\n\n const testSuite: IJUnitTestSuite = {\n name: this.suiteName,\n tests,\n failures,\n skipped,\n time: tests.reduce((total, test) => total + test.time, 0),\n }\n\n this.log(this.buildXmlReport(testSuite))\n }\n\n private buildXmlReport(testSuite: IJUnitTestSuite): string {\n const xmlReport = xmlbuilder\n .create('testsuite', { invalidCharReplacement: '' })\n .att('failures', testSuite.failures)\n .att('skipped', testSuite.skipped)\n .att('name', testSuite.name)\n .att('time', testSuite.time)\n .att('tests', testSuite.tests.length)\n testSuite.tests.forEach((test) => {\n const xmlTestCase = xmlReport.ele('testcase', {\n classname: test.classname,\n name: test.name,\n time: test.time,\n })\n if (test.result.status === TestStepResultStatus.SKIPPED) {\n xmlTestCase.ele('skipped')\n } else if (test.result.status !== TestStepResultStatus.PASSED) {\n const xmlFailure = xmlTestCase.ele('failure', {\n type: test.result.failure?.type,\n message: test.result.failure?.message,\n })\n if (test.result?.failure) {\n xmlFailure.cdata(test.result.failure.detail)\n }\n }\n xmlTestCase.ele('system-out', {}).cdata(test.systemOutput)\n })\n\n return xmlReport.end({ pretty: true })\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import Formatter, { IFormatterOptions } from '.';
2
+ export default class MessageFormatter extends Formatter {
3
+ static readonly documentation: string;
4
+ constructor(options: IFormatterOptions);
5
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _1 = __importDefault(require("."));
7
+ class MessageFormatter extends _1.default {
8
+ constructor(options) {
9
+ super(options);
10
+ options.eventBroadcaster.on('envelope', (envelope) => this.log(JSON.stringify(envelope) + '\n'));
11
+ }
12
+ }
13
+ exports.default = MessageFormatter;
14
+ MessageFormatter.documentation = 'Outputs protobuf messages';
15
+ //# sourceMappingURL=message_formatter.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,18 @@
1
+ import Formatter, { IFormatterOptions } from './';
2
+ import ProgressBar from 'progress';
3
+ import * as messages from '@cucumber/messages';
4
+ export default class ProgressBarFormatter extends Formatter {
5
+ private numberOfSteps;
6
+ private testRunStarted;
7
+ private issueCount;
8
+ progressBar: ProgressBar;
9
+ static readonly documentation: string;
10
+ constructor(options: IFormatterOptions);
11
+ incrementStepCount(pickleId: string): void;
12
+ initializeProgressBar(): void;
13
+ logProgress({ testStepId, testCaseStartedId, }: messages.TestStepFinished): void;
14
+ logUndefinedParametertype(parameterType: messages.UndefinedParameterType): void;
15
+ logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void;
16
+ logSummary(testRunFinished: messages.TestRunFinished): void;
17
+ parseEnvelope(envelope: messages.Envelope): void;
18
+ }