@dev-blinq/cucumber-js 1.0.0-amdocs

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 (371) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -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/bin/cucumber.ts +2 -0
  7. package/bin/download-install.js +167 -0
  8. package/lib/api/console_logger.d.ts +12 -0
  9. package/lib/api/console_logger.js +24 -0
  10. package/lib/api/console_logger.js.map +1 -0
  11. package/lib/api/convert_configuration.d.ts +4 -0
  12. package/lib/api/convert_configuration.js +66 -0
  13. package/lib/api/convert_configuration.js.map +1 -0
  14. package/lib/api/environment.d.ts +2 -0
  15. package/lib/api/environment.js +14 -0
  16. package/lib/api/environment.js.map +1 -0
  17. package/lib/api/formatters.d.ts +20 -0
  18. package/lib/api/formatters.js +61 -0
  19. package/lib/api/formatters.js.map +1 -0
  20. package/lib/api/gherkin.d.ts +21 -0
  21. package/lib/api/gherkin.js +146 -0
  22. package/lib/api/gherkin.js.map +1 -0
  23. package/lib/api/index.d.ts +12 -0
  24. package/lib/api/index.js +28 -0
  25. package/lib/api/index.js.map +1 -0
  26. package/lib/api/load_configuration.d.ts +9 -0
  27. package/lib/api/load_configuration.js +41 -0
  28. package/lib/api/load_configuration.js.map +1 -0
  29. package/lib/api/load_sources.d.ts +9 -0
  30. package/lib/api/load_sources.js +53 -0
  31. package/lib/api/load_sources.js.map +1 -0
  32. package/lib/api/load_support.d.ts +10 -0
  33. package/lib/api/load_support.js +30 -0
  34. package/lib/api/load_support.js.map +1 -0
  35. package/lib/api/paths.d.ts +8 -0
  36. package/lib/api/paths.js +102 -0
  37. package/lib/api/paths.js.map +1 -0
  38. package/lib/api/plugins.d.ts +4 -0
  39. package/lib/api/plugins.js +19 -0
  40. package/lib/api/plugins.js.map +1 -0
  41. package/lib/api/run_cucumber.d.ts +11 -0
  42. package/lib/api/run_cucumber.js +115 -0
  43. package/lib/api/run_cucumber.js.map +1 -0
  44. package/lib/api/runtime.d.ts +21 -0
  45. package/lib/api/runtime.js +36 -0
  46. package/lib/api/runtime.js.map +1 -0
  47. package/lib/api/support.d.ts +9 -0
  48. package/lib/api/support.js +26 -0
  49. package/lib/api/support.js.map +1 -0
  50. package/lib/api/test_helpers.d.ts +3 -0
  51. package/lib/api/test_helpers.js +36 -0
  52. package/lib/api/test_helpers.js.map +1 -0
  53. package/lib/api/types.d.ts +177 -0
  54. package/lib/api/types.js +3 -0
  55. package/lib/api/types.js.map +1 -0
  56. package/lib/api/wrapper.mjs +6 -0
  57. package/lib/cli/helpers.d.ts +39 -0
  58. package/lib/cli/helpers.js +224 -0
  59. package/lib/cli/helpers.js.map +1 -0
  60. package/lib/cli/i18n.d.ts +2 -0
  61. package/lib/cli/i18n.js +70 -0
  62. package/lib/cli/i18n.js.map +1 -0
  63. package/lib/cli/index.d.ts +21 -0
  64. package/lib/cli/index.js +64 -0
  65. package/lib/cli/index.js.map +1 -0
  66. package/lib/cli/install_validator.d.ts +1 -0
  67. package/lib/cli/install_validator.js +18 -0
  68. package/lib/cli/install_validator.js.map +1 -0
  69. package/lib/cli/run.d.ts +1 -0
  70. package/lib/cli/run.js +44 -0
  71. package/lib/cli/run.js.map +1 -0
  72. package/lib/cli/validate_node_engine_version.d.ts +10 -0
  73. package/lib/cli/validate_node_engine_version.js +24 -0
  74. package/lib/cli/validate_node_engine_version.js.map +1 -0
  75. package/lib/configuration/argv_parser.d.ts +20 -0
  76. package/lib/configuration/argv_parser.js +104 -0
  77. package/lib/configuration/argv_parser.js.map +1 -0
  78. package/lib/configuration/axios_client.d.ts +1 -0
  79. package/lib/configuration/axios_client.js +40 -0
  80. package/lib/configuration/axios_client.js.map +1 -0
  81. package/lib/configuration/check_schema.d.ts +2 -0
  82. package/lib/configuration/check_schema.js +60 -0
  83. package/lib/configuration/check_schema.js.map +1 -0
  84. package/lib/configuration/default_configuration.d.ts +2 -0
  85. package/lib/configuration/default_configuration.js +29 -0
  86. package/lib/configuration/default_configuration.js.map +1 -0
  87. package/lib/configuration/from_file.d.ts +3 -0
  88. package/lib/configuration/from_file.js +85 -0
  89. package/lib/configuration/from_file.js.map +1 -0
  90. package/lib/configuration/helpers.d.ts +1 -0
  91. package/lib/configuration/helpers.js +11 -0
  92. package/lib/configuration/helpers.js.map +1 -0
  93. package/lib/configuration/index.d.ts +7 -0
  94. package/lib/configuration/index.js +29 -0
  95. package/lib/configuration/index.js.map +1 -0
  96. package/lib/configuration/locate_file.d.ts +1 -0
  97. package/lib/configuration/locate_file.js +21 -0
  98. package/lib/configuration/locate_file.js.map +1 -0
  99. package/lib/configuration/merge_configurations.d.ts +2 -0
  100. package/lib/configuration/merge_configurations.js +48 -0
  101. package/lib/configuration/merge_configurations.js.map +1 -0
  102. package/lib/configuration/option_splitter.d.ts +3 -0
  103. package/lib/configuration/option_splitter.js +23 -0
  104. package/lib/configuration/option_splitter.js.map +1 -0
  105. package/lib/configuration/types.d.ts +30 -0
  106. package/lib/configuration/types.js +3 -0
  107. package/lib/configuration/types.js.map +1 -0
  108. package/lib/configuration/validate_configuration.d.ts +3 -0
  109. package/lib/configuration/validate_configuration.js +13 -0
  110. package/lib/configuration/validate_configuration.js.map +1 -0
  111. package/lib/filter_stack_trace.d.ts +3 -0
  112. package/lib/filter_stack_trace.js +38 -0
  113. package/lib/filter_stack_trace.js.map +1 -0
  114. package/lib/formatter/api.d.ts +2 -0
  115. package/lib/formatter/api.js +53 -0
  116. package/lib/formatter/api.js.map +1 -0
  117. package/lib/formatter/builder.d.ts +37 -0
  118. package/lib/formatter/builder.js +101 -0
  119. package/lib/formatter/builder.js.map +1 -0
  120. package/lib/formatter/bvt_analysis_formatter.d.ts +30 -0
  121. package/lib/formatter/bvt_analysis_formatter.js +334 -0
  122. package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
  123. package/lib/formatter/feature_data_format.d.ts +23 -0
  124. package/lib/formatter/feature_data_format.js +182 -0
  125. package/lib/formatter/feature_data_format.js.map +1 -0
  126. package/lib/formatter/fixtures/typescript.d.ts +2 -0
  127. package/lib/formatter/fixtures/typescript.js +6 -0
  128. package/lib/formatter/fixtures/typescript.js.map +1 -0
  129. package/lib/formatter/get_color_fns.d.ts +15 -0
  130. package/lib/formatter/get_color_fns.js +56 -0
  131. package/lib/formatter/get_color_fns.js.map +1 -0
  132. package/lib/formatter/helpers/constants.d.ts +44 -0
  133. package/lib/formatter/helpers/constants.js +50 -0
  134. package/lib/formatter/helpers/constants.js.map +1 -0
  135. package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
  136. package/lib/formatter/helpers/duration_helpers.js +9 -0
  137. package/lib/formatter/helpers/duration_helpers.js.map +1 -0
  138. package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
  139. package/lib/formatter/helpers/event_data_collector.js +126 -0
  140. package/lib/formatter/helpers/event_data_collector.js.map +1 -0
  141. package/lib/formatter/helpers/formatters.d.ts +6 -0
  142. package/lib/formatter/helpers/formatters.js +45 -0
  143. package/lib/formatter/helpers/formatters.js.map +1 -0
  144. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
  145. package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
  146. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
  147. package/lib/formatter/helpers/index.d.ts +10 -0
  148. package/lib/formatter/helpers/index.js +52 -0
  149. package/lib/formatter/helpers/index.js.map +1 -0
  150. package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
  151. package/lib/formatter/helpers/issue_helpers.js +59 -0
  152. package/lib/formatter/helpers/issue_helpers.js.map +1 -0
  153. package/lib/formatter/helpers/keyword_type.d.ts +11 -0
  154. package/lib/formatter/helpers/keyword_type.js +32 -0
  155. package/lib/formatter/helpers/keyword_type.js.map +1 -0
  156. package/lib/formatter/helpers/location_helpers.d.ts +2 -0
  157. package/lib/formatter/helpers/location_helpers.js +17 -0
  158. package/lib/formatter/helpers/location_helpers.js.map +1 -0
  159. package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
  160. package/lib/formatter/helpers/pickle_parser.js +28 -0
  161. package/lib/formatter/helpers/pickle_parser.js.map +1 -0
  162. package/lib/formatter/helpers/report_generator.d.ts +148 -0
  163. package/lib/formatter/helpers/report_generator.js +573 -0
  164. package/lib/formatter/helpers/report_generator.js.map +1 -0
  165. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
  166. package/lib/formatter/helpers/step_argument_formatter.js +48 -0
  167. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
  168. package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
  169. package/lib/formatter/helpers/summary_helpers.js +96 -0
  170. package/lib/formatter/helpers/summary_helpers.js.map +1 -0
  171. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
  172. package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
  173. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
  174. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
  175. package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
  176. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
  177. package/lib/formatter/helpers/upload_serivce.d.ts +26 -0
  178. package/lib/formatter/helpers/upload_serivce.js +237 -0
  179. package/lib/formatter/helpers/upload_serivce.js.map +1 -0
  180. package/lib/formatter/helpers/uploader.d.ts +12 -0
  181. package/lib/formatter/helpers/uploader.js +151 -0
  182. package/lib/formatter/helpers/uploader.js.map +1 -0
  183. package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
  184. package/lib/formatter/helpers/usage_helpers/index.js +111 -0
  185. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
  186. package/lib/formatter/html_formatter.d.ts +7 -0
  187. package/lib/formatter/html_formatter.js +30 -0
  188. package/lib/formatter/html_formatter.js.map +1 -0
  189. package/lib/formatter/index.d.ts +53 -0
  190. package/lib/formatter/index.js +21 -0
  191. package/lib/formatter/index.js.map +1 -0
  192. package/lib/formatter/json_formatter.d.ts +78 -0
  193. package/lib/formatter/json_formatter.js +230 -0
  194. package/lib/formatter/json_formatter.js.map +1 -0
  195. package/lib/formatter/junit_formatter.d.ts +17 -0
  196. package/lib/formatter/junit_formatter.js +181 -0
  197. package/lib/formatter/junit_formatter.js.map +1 -0
  198. package/lib/formatter/message_formatter.d.ts +5 -0
  199. package/lib/formatter/message_formatter.js +15 -0
  200. package/lib/formatter/message_formatter.js.map +1 -0
  201. package/lib/formatter/progress_bar_formatter.d.ts +18 -0
  202. package/lib/formatter/progress_bar_formatter.js +99 -0
  203. package/lib/formatter/progress_bar_formatter.js.map +1 -0
  204. package/lib/formatter/progress_formatter.d.ts +9 -0
  205. package/lib/formatter/progress_formatter.js +59 -0
  206. package/lib/formatter/progress_formatter.js.map +1 -0
  207. package/lib/formatter/rerun_formatter.d.ts +13 -0
  208. package/lib/formatter/rerun_formatter.js +80 -0
  209. package/lib/formatter/rerun_formatter.js.map +1 -0
  210. package/lib/formatter/snippets_formatter.d.ts +6 -0
  211. package/lib/formatter/snippets_formatter.js +61 -0
  212. package/lib/formatter/snippets_formatter.js.map +1 -0
  213. package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
  214. package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
  215. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
  216. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
  217. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
  218. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
  219. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
  220. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
  221. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
  222. package/lib/formatter/summary_formatter.d.ts +14 -0
  223. package/lib/formatter/summary_formatter.js +68 -0
  224. package/lib/formatter/summary_formatter.js.map +1 -0
  225. package/lib/formatter/usage_formatter.d.ts +6 -0
  226. package/lib/formatter/usage_formatter.js +98 -0
  227. package/lib/formatter/usage_formatter.js.map +1 -0
  228. package/lib/formatter/usage_json_formatter.d.ts +7 -0
  229. package/lib/formatter/usage_json_formatter.js +34 -0
  230. package/lib/formatter/usage_json_formatter.js.map +1 -0
  231. package/lib/importer.js +13 -0
  232. package/lib/index.d.ts +58 -0
  233. package/lib/index.js +109 -0
  234. package/lib/index.js.map +1 -0
  235. package/lib/logger.d.ts +5 -0
  236. package/lib/logger.js +3 -0
  237. package/lib/logger.js.map +1 -0
  238. package/lib/models/data_table.d.ts +10 -0
  239. package/lib/models/data_table.js +46 -0
  240. package/lib/models/data_table.js.map +1 -0
  241. package/lib/models/definition.d.ts +55 -0
  242. package/lib/models/definition.js +22 -0
  243. package/lib/models/definition.js.map +1 -0
  244. package/lib/models/gherkin_step_keyword.d.ts +1 -0
  245. package/lib/models/gherkin_step_keyword.js +3 -0
  246. package/lib/models/gherkin_step_keyword.js.map +1 -0
  247. package/lib/models/pickle_order.d.ts +1 -0
  248. package/lib/models/pickle_order.js +3 -0
  249. package/lib/models/pickle_order.js.map +1 -0
  250. package/lib/models/step_definition.d.ts +11 -0
  251. package/lib/models/step_definition.js +37 -0
  252. package/lib/models/step_definition.js.map +1 -0
  253. package/lib/models/test_case_hook_definition.d.ts +10 -0
  254. package/lib/models/test_case_hook_definition.js +27 -0
  255. package/lib/models/test_case_hook_definition.js.map +1 -0
  256. package/lib/models/test_run_hook_definition.d.ts +3 -0
  257. package/lib/models/test_run_hook_definition.js +10 -0
  258. package/lib/models/test_run_hook_definition.js.map +1 -0
  259. package/lib/models/test_step_hook_definition.d.ts +9 -0
  260. package/lib/models/test_step_hook_definition.js +26 -0
  261. package/lib/models/test_step_hook_definition.js.map +1 -0
  262. package/lib/pickle_filter.d.ts +42 -0
  263. package/lib/pickle_filter.js +99 -0
  264. package/lib/pickle_filter.js.map +1 -0
  265. package/lib/plugin/index.d.ts +2 -0
  266. package/lib/plugin/index.js +19 -0
  267. package/lib/plugin/index.js.map +1 -0
  268. package/lib/plugin/plugin_manager.d.ts +13 -0
  269. package/lib/plugin/plugin_manager.js +36 -0
  270. package/lib/plugin/plugin_manager.js.map +1 -0
  271. package/lib/plugin/types.d.ts +14 -0
  272. package/lib/plugin/types.js +3 -0
  273. package/lib/plugin/types.js.map +1 -0
  274. package/lib/publish/http_stream.d.ts +30 -0
  275. package/lib/publish/http_stream.js +112 -0
  276. package/lib/publish/http_stream.js.map +1 -0
  277. package/lib/publish/index.d.ts +2 -0
  278. package/lib/publish/index.js +5 -0
  279. package/lib/publish/index.js.map +1 -0
  280. package/lib/publish/publish_plugin.d.ts +2 -0
  281. package/lib/publish/publish_plugin.js +48 -0
  282. package/lib/publish/publish_plugin.js.map +1 -0
  283. package/lib/runtime/assemble_test_cases.d.ts +13 -0
  284. package/lib/runtime/assemble_test_cases.js +88 -0
  285. package/lib/runtime/assemble_test_cases.js.map +1 -0
  286. package/lib/runtime/attachment_manager/index.d.ts +33 -0
  287. package/lib/runtime/attachment_manager/index.js +119 -0
  288. package/lib/runtime/attachment_manager/index.js.map +1 -0
  289. package/lib/runtime/format_error.d.ts +2 -0
  290. package/lib/runtime/format_error.js +36 -0
  291. package/lib/runtime/format_error.js.map +1 -0
  292. package/lib/runtime/helpers.d.ts +6 -0
  293. package/lib/runtime/helpers.js +101 -0
  294. package/lib/runtime/helpers.js.map +1 -0
  295. package/lib/runtime/index.d.ts +40 -0
  296. package/lib/runtime/index.js +76 -0
  297. package/lib/runtime/index.js.map +1 -0
  298. package/lib/runtime/parallel/command_types.d.ts +32 -0
  299. package/lib/runtime/parallel/command_types.js +3 -0
  300. package/lib/runtime/parallel/command_types.js.map +1 -0
  301. package/lib/runtime/parallel/coordinator.d.ts +72 -0
  302. package/lib/runtime/parallel/coordinator.js +222 -0
  303. package/lib/runtime/parallel/coordinator.js.map +1 -0
  304. package/lib/runtime/parallel/run_worker.d.ts +1 -0
  305. package/lib/runtime/parallel/run_worker.js +29 -0
  306. package/lib/runtime/parallel/run_worker.js.map +1 -0
  307. package/lib/runtime/parallel/worker.d.ts +26 -0
  308. package/lib/runtime/parallel/worker.js +87 -0
  309. package/lib/runtime/parallel/worker.js.map +1 -0
  310. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  311. package/lib/runtime/run_test_run_hooks.js +28 -0
  312. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  313. package/lib/runtime/step_runner.d.ts +16 -0
  314. package/lib/runtime/step_runner.js +88 -0
  315. package/lib/runtime/step_runner.js.map +1 -0
  316. package/lib/runtime/stopwatch.d.ts +12 -0
  317. package/lib/runtime/stopwatch.js +34 -0
  318. package/lib/runtime/stopwatch.js.map +1 -0
  319. package/lib/runtime/test_case_runner.d.ts +55 -0
  320. package/lib/runtime/test_case_runner.js +277 -0
  321. package/lib/runtime/test_case_runner.js.map +1 -0
  322. package/lib/step_arguments.d.ts +6 -0
  323. package/lib/step_arguments.js +19 -0
  324. package/lib/step_arguments.js.map +1 -0
  325. package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
  326. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  327. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  328. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  329. package/lib/support_code_library_builder/get_definition_line_and_uri.js +29 -0
  330. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  331. package/lib/support_code_library_builder/index.d.ts +74 -0
  332. package/lib/support_code_library_builder/index.js +304 -0
  333. package/lib/support_code_library_builder/index.js.map +1 -0
  334. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  335. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  336. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  337. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -0
  338. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
  339. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
  340. package/lib/support_code_library_builder/types.d.ts +88 -0
  341. package/lib/support_code_library_builder/types.js +3 -0
  342. package/lib/support_code_library_builder/types.js.map +1 -0
  343. package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
  344. package/lib/support_code_library_builder/validate_arguments.js +73 -0
  345. package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
  346. package/lib/support_code_library_builder/world.d.ts +18 -0
  347. package/lib/support_code_library_builder/world.js +11 -0
  348. package/lib/support_code_library_builder/world.js.map +1 -0
  349. package/lib/time.d.ts +18 -0
  350. package/lib/time.js +61 -0
  351. package/lib/time.js.map +1 -0
  352. package/lib/try_require.d.ts +7 -0
  353. package/lib/try_require.js +26 -0
  354. package/lib/try_require.js.map +1 -0
  355. package/lib/types/index.d.ts +4 -0
  356. package/lib/types/index.js +3 -0
  357. package/lib/types/index.js.map +1 -0
  358. package/lib/uncaught_exception_manager.d.ts +7 -0
  359. package/lib/uncaught_exception_manager.js +12 -0
  360. package/lib/uncaught_exception_manager.js.map +1 -0
  361. package/lib/user_code_runner.d.ts +14 -0
  362. package/lib/user_code_runner.js +82 -0
  363. package/lib/user_code_runner.js.map +1 -0
  364. package/lib/value_checker.d.ts +3 -0
  365. package/lib/value_checker.js +19 -0
  366. package/lib/value_checker.js.map +1 -0
  367. package/lib/version.d.ts +1 -0
  368. package/lib/version.js +6 -0
  369. package/lib/version.js.map +1 -0
  370. package/lib/wrapper.mjs +44 -0
  371. package/package.json +197 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html_formatter.js","sourceRoot":"","sources":["../../src/formatter/html_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAEhD,8DAAoC;AACpC,8EAAyD;AACzD,mCAAiC;AACjC,+BAAgC;AAEhC,MAAqB,aAAc,SAAQ,UAAS;IAIlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAkB,CACvC,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,eAAe,CAClB,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,IAAA,gBAAS,EAAC,iBAAQ,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC3C,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;;AAtBH,gCAuBC;AArBwB,2BAAa,GAAW,qBAAqB,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\nimport resolvePkg from 'resolve-pkg'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport { finished } from 'stream'\nimport { promisify } from 'util'\n\nexport default class HtmlFormatter extends Formatter {\n private readonly _htmlStream: CucumberHtmlStream\n public static readonly documentation: string = 'Outputs HTML report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this._htmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n this._htmlStream.write(envelope)\n })\n this._htmlStream.on('data', (chunk) => this.log(chunk))\n }\n\n async finished(): Promise<void> {\n this._htmlStream.end()\n await promisify(finished)(this._htmlStream)\n await super.finished()\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { IColorFns } from './get_color_fns';
4
+ import { EventDataCollector } from './helpers';
5
+ import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
6
+ import { Writable } from 'stream';
7
+ import { ISupportCodeLibrary } from '../support_code_library_builder/types';
8
+ import { EventEmitter } from 'events';
9
+ import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
10
+ export interface FormatRerunOptions {
11
+ separator?: string;
12
+ }
13
+ export interface FormatOptions {
14
+ colorsEnabled?: boolean;
15
+ rerun?: FormatRerunOptions;
16
+ snippetInterface?: SnippetInterface;
17
+ snippetSyntax?: string;
18
+ printAttachments?: boolean;
19
+ [customKey: string]: any;
20
+ }
21
+ export interface IPublishConfig {
22
+ url: string;
23
+ token: string;
24
+ }
25
+ export type IFormatterStream = Writable;
26
+ export type IFormatterLogFn = (buffer: string | Uint8Array) => void;
27
+ export type IFormatterCleanupFn = () => Promise<any>;
28
+ export interface IFormatterOptions {
29
+ colorFns: IColorFns;
30
+ cwd: string;
31
+ eventBroadcaster: EventEmitter;
32
+ eventDataCollector: EventDataCollector;
33
+ log: IFormatterLogFn;
34
+ parsedArgvOptions: FormatOptions;
35
+ snippetBuilder: StepDefinitionSnippetBuilder;
36
+ stream: Writable;
37
+ cleanup: IFormatterCleanupFn;
38
+ supportCodeLibrary: ISupportCodeLibrary;
39
+ }
40
+ export default class Formatter {
41
+ protected colorFns: IColorFns;
42
+ protected cwd: string;
43
+ protected eventDataCollector: EventDataCollector;
44
+ protected log: IFormatterLogFn;
45
+ protected snippetBuilder: StepDefinitionSnippetBuilder;
46
+ protected stream: Writable;
47
+ protected supportCodeLibrary: ISupportCodeLibrary;
48
+ protected printAttachments: boolean;
49
+ private readonly cleanup;
50
+ static readonly documentation: string;
51
+ constructor(options: IFormatterOptions);
52
+ finished(): Promise<void>;
53
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const value_checker_1 = require("../value_checker");
4
+ class Formatter {
5
+ constructor(options) {
6
+ this.colorFns = options.colorFns;
7
+ this.cwd = options.cwd;
8
+ this.eventDataCollector = options.eventDataCollector;
9
+ this.log = options.log;
10
+ this.snippetBuilder = options.snippetBuilder;
11
+ this.stream = options.stream;
12
+ this.supportCodeLibrary = options.supportCodeLibrary;
13
+ this.cleanup = options.cleanup;
14
+ this.printAttachments = (0, value_checker_1.valueOrDefault)(options.parsedArgvOptions.printAttachments, true);
15
+ }
16
+ async finished() {
17
+ await this.cleanup();
18
+ }
19
+ }
20
+ exports.default = Formatter;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAMA,oDAAiD;AAsCjD,MAAqB,SAAS;IAY5B,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { Writable } from 'stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { EventEmitter } from 'events'\nimport { valueOrDefault } from '../value_checker'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport interface IPublishConfig {\n url: string\n token: string\n}\n\nexport type IFormatterStream = Writable\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: Writable\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: Writable\n protected supportCodeLibrary: ISupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
@@ -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,C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AI,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;;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