@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,88 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.run = void 0;
30
+ const stopwatch_1 = require("./stopwatch");
31
+ const user_code_runner_1 = __importDefault(require("../user_code_runner"));
32
+ const messages = __importStar(require("@cucumber/messages"));
33
+ const value_checker_1 = require("../value_checker");
34
+ const format_error_1 = require("./format_error");
35
+ async function run({ defaultTimeout, filterStackTraces, hookParameter, step, stepDefinition, world, }) {
36
+ const stopwatch = (0, stopwatch_1.create)().start();
37
+ let error, result, invocationData;
38
+ try {
39
+ invocationData = await stepDefinition.getInvocationParameters({
40
+ hookParameter,
41
+ step,
42
+ world,
43
+ });
44
+ }
45
+ catch (err) {
46
+ error = err;
47
+ }
48
+ if ((0, value_checker_1.doesNotHaveValue)(error)) {
49
+ const timeoutInMilliseconds = (0, value_checker_1.valueOrDefault)(stepDefinition.options.timeout, defaultTimeout);
50
+ if (invocationData.validCodeLengths.includes(stepDefinition.code.length)) {
51
+ const data = await user_code_runner_1.default.run({
52
+ argsArray: invocationData.parameters,
53
+ fn: stepDefinition.code,
54
+ thisArg: world,
55
+ timeoutInMilliseconds,
56
+ });
57
+ error = data.error;
58
+ result = data.result;
59
+ }
60
+ else {
61
+ error = invocationData.getInvalidCodeLengthMessage();
62
+ }
63
+ }
64
+ const duration = stopwatch.stop().duration();
65
+ let status;
66
+ let details = {};
67
+ if (result === 'skipped') {
68
+ status = messages.TestStepResultStatus.SKIPPED;
69
+ }
70
+ else if (result === 'pending') {
71
+ status = messages.TestStepResultStatus.PENDING;
72
+ }
73
+ else if ((0, value_checker_1.doesHaveValue)(error)) {
74
+ details = (0, format_error_1.formatError)(error, filterStackTraces);
75
+ status = messages.TestStepResultStatus.FAILED;
76
+ }
77
+ else {
78
+ status = messages.TestStepResultStatus.PASSED;
79
+ }
80
+ return {
81
+ duration,
82
+ status,
83
+ ...details,
84
+ };
85
+ }
86
+ exports.run = run;
87
+ exports.default = { run };
88
+ //# sourceMappingURL=step_runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step_runner.js","sourceRoot":"","sources":["../../src/runtime/step_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoC;AACpC,2EAAgD;AAChD,6DAA8C;AAG9C,oDAIyB;AACzB,iDAA4C;AAWrC,KAAK,UAAU,GAAG,CAAC,EACxB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,cAAc,EACd,KAAK,GACO;IACZ,MAAM,SAAS,GAAG,IAAA,kBAAM,GAAE,CAAC,KAAK,EAAE,CAAA;IAClC,IAAI,KAAU,EAAE,M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BAAiB,CAAC,CAAA;QAC/C,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;SAAM;QACL,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;IAED,OAAO;QACL,QAAQ;QACR,MAAM;QACN,GAAG,OAAO;KACX,CAAA;AACH,CAAC;AA5DD,kBA4DC;AAED,kBAAe,EAAE,GAAG,EAAE,CAAA","sourcesContent":["import { create } from './stopwatch'\nimport UserCodeRunner from '../user_code_runner'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseHookParameter } from '../support_code_library_builder/types'\nimport { IDefinition, IGetInvocationDataResponse } from '../models/definition'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\nimport { formatError } from './format_error'\n\nexport interface IRunOptions {\n defaultTimeout: number\n filterStackTraces: boolean\n hookParameter: ITestCaseHookParameter\n step: messages.PickleStep\n stepDefinition: IDefinition\n world: any\n}\n\nexport async function run({\n defaultTimeout,\n filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world,\n}: IRunOptions): Promise<messages.TestStepResult> {\n const stopwatch = create().start()\n let error: any, result: any, invocationData: IGetInvocationDataResponse\n\n try {\n invocationData = await stepDefinition.getInvocationParameters({\n hookParameter,\n step,\n world,\n })\n } catch (err) {\n error = err\n }\n\n if (doesNotHaveValue(error)) {\n const timeoutInMilliseconds = valueOrDefault(\n stepDefinition.options.timeout,\n defaultTimeout\n )\n\n if (invocationData.validCodeLengths.includes(stepDefinition.code.length)) {\n const data = await UserCodeRunner.run({\n argsArray: invocationData.parameters,\n fn: stepDefinition.code,\n thisArg: world,\n timeoutInMilliseconds,\n })\n error = data.error\n result = data.result\n } else {\n error = invocationData.getInvalidCodeLengthMessage()\n }\n }\n\n const duration = stopwatch.stop().duration()\n let status: messages.TestStepResultStatus\n let details = {}\n if (result === 'skipped') {\n status = messages.TestStepResultStatus.SKIPPED\n } else if (result === 'pending') {\n status = messages.TestStepResultStatus.PENDING\n } else if (doesHaveValue(error)) {\n details = formatError(error, filterStackTraces)\n status = messages.TestStepResultStatus.FAILED\n } else {\n status = messages.TestStepResultStatus.PASSED\n }\n\n return {\n duration,\n status,\n ...details,\n }\n}\n\nexport default { run }\n"]}
@@ -0,0 +1,12 @@
1
+ import { Duration, Timestamp } from '@cucumber/messages';
2
+ /**
3
+ * A utility for timing test run operations and returning duration and
4
+ * timestamp objects in messages-compatible formats
5
+ */
6
+ export interface IStopwatch {
7
+ start: () => IStopwatch;
8
+ stop: () => IStopwatch;
9
+ duration: () => Duration;
10
+ timestamp: () => Timestamp;
11
+ }
12
+ export declare const create: (base?: Duration) => IStopwatch;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.create = void 0;
7
+ const messages_1 = require("@cucumber/messages");
8
+ const time_1 = __importDefault(require("../time"));
9
+ class StopwatchImpl {
10
+ constructor(base = { seconds: 0, nanos: 0 }) {
11
+ this.base = base;
12
+ }
13
+ start() {
14
+ this.started = time_1.default.performance.now();
15
+ return this;
16
+ }
17
+ stop() {
18
+ this.base = this.duration();
19
+ this.started = undefined;
20
+ return this;
21
+ }
22
+ duration() {
23
+ if (typeof this.started !== 'number') {
24
+ return this.base;
25
+ }
26
+ return messages_1.TimeConversion.addDurations(this.base, messages_1.TimeConversion.millisecondsToDuration(time_1.default.performance.now() - this.started));
27
+ }
28
+ timestamp() {
29
+ return messages_1.TimeConversion.millisecondsSinceEpochToTimestamp(time_1.default.Date.now());
30
+ }
31
+ }
32
+ const create = (base) => new StopwatchImpl(base);
33
+ exports.create = create;
34
+ //# sourceMappingURL=stopwatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopwatch.js","sourceRoot":"","sources":["../../src/runtime/stopwatch.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAwE;AACxE,mDAA6B;AAa7B,MAAM,aAAa;IAGjB,YAAoB,OAAiB,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAAzC,SAAI,GAAJ,IAAI,CAAqC;IAAG,CAAC;IAEjE,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,cAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;QACxC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI;QACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAA;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ;QACN,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE;YACpC,OAAO,IAAI,CAAC,IAAI,CAAA;SACjB;QACD,OAAO,yBAAc,CAAC,YAAY,CAChC,IAAI,CAAC,IAAI,EACT,yBAAc,CAAC,sBAAsB,CACnC,cAAO,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CACzC,CACF,CAAA;IACH,CAAC;IAED,SAAS;QACP,OAAO,yBAAc,CAAC,iCAAiC,CAAC,cAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAC7E,CAAC;CACF;AAEM,MAAM,MAAM,GAAG,CAAC,IAAe,EAAc,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAA;AAAjE,QAAA,MAAM,UAA2D","sourcesContent":["import { Duration, TimeConversion, Timestamp } from '@cucumber/messages'\nimport methods from '../time'\n\n/**\n * A utility for timing test run operations and returning duration and\n * timestamp objects in messages-compatible formats\n */\nexport interface IStopwatch {\n start: () => IStopwatch\n stop: () => IStopwatch\n duration: () => Duration\n timestamp: () => Timestamp\n}\n\nclass StopwatchImpl implements IStopwatch {\n private started: number\n\n constructor(private base: Duration = { seconds: 0, nanos: 0 }) {}\n\n start(): IStopwatch {\n this.started = methods.performance.now()\n return this\n }\n\n stop(): IStopwatch {\n this.base = this.duration()\n this.started = undefined\n return this\n }\n\n duration(): Duration {\n if (typeof this.started !== 'number') {\n return this.base\n }\n return TimeConversion.addDurations(\n this.base,\n TimeConversion.millisecondsToDuration(\n methods.performance.now() - this.started\n )\n )\n }\n\n timestamp(): Timestamp {\n return TimeConversion.millisecondsSinceEpochToTimestamp(methods.Date.now())\n }\n}\n\nexport const create = (base?: Duration): IStopwatch => new StopwatchImpl(base)\n"]}
@@ -0,0 +1,54 @@
1
+ /// <reference types="node" />
2
+ import * as messages from '@cucumber/messages';
3
+ import { IdGenerator } from '@cucumber/messages';
4
+ import { EventEmitter } from 'events';
5
+ import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
6
+ import TestCaseHookDefinition from '../models/test_case_hook_definition';
7
+ import TestStepHookDefinition from '../models/test_step_hook_definition';
8
+ import { IDefinition } from '../models/definition';
9
+ import { IStopwatch } from './stopwatch';
10
+ export interface INewTestCaseRunnerOptions {
11
+ eventBroadcaster: EventEmitter;
12
+ stopwatch: IStopwatch;
13
+ gherkinDocument: messages.GherkinDocument;
14
+ newId: IdGenerator.NewId;
15
+ pickle: messages.Pickle;
16
+ testCase: messages.TestCase;
17
+ retries: number;
18
+ skip: boolean;
19
+ filterStackTraces: boolean;
20
+ supportCodeLibrary: ISupportCodeLibrary;
21
+ worldParameters: any;
22
+ }
23
+ export default class TestCaseRunner {
24
+ private readonly attachmentManager;
25
+ private currentTestCaseStartedId;
26
+ private currentTestStepId;
27
+ private readonly eventBroadcaster;
28
+ private readonly stopwatch;
29
+ private readonly gherkinDocument;
30
+ private readonly newId;
31
+ private readonly pickle;
32
+ private readonly testCase;
33
+ private readonly maxAttempts;
34
+ private readonly skip;
35
+ private readonly filterStackTraces;
36
+ private readonly supportCodeLibrary;
37
+ private testStepResults;
38
+ private world;
39
+ private readonly worldParameters;
40
+ constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries, skip, filterStackTraces, supportCodeLibrary, worldParameters, }: INewTestCaseRunnerOptions);
41
+ resetTestProgressData(): void;
42
+ getBeforeStepHookDefinitions(): TestStepHookDefinition[];
43
+ getAfterStepHookDefinitions(): TestStepHookDefinition[];
44
+ getWorstStepResult(): messages.TestStepResult;
45
+ invokeStep(step: messages.PickleStep, stepDefinition: IDefinition, hookParameter?: any): Promise<messages.TestStepResult>;
46
+ isSkippingSteps(): boolean;
47
+ shouldSkipHook(isBeforeHook: boolean): boolean;
48
+ aroundTestStep(testStepId: string, runStepFn: () => Promise<messages.TestStepResult>): Promise<void>;
49
+ run(): Promise<messages.TestStepResultStatus>;
50
+ runAttempt(attempt: number, moreAttemptsRemaining: boolean): Promise<boolean>;
51
+ runHook(hookDefinition: TestCaseHookDefinition, hookParameter: ITestCaseHookParameter, isBeforeHook: boolean): Promise<messages.TestStepResult>;
52
+ runStepHooks(stepHooks: TestStepHookDefinition[], pickleStep: messages.PickleStep, stepResult?: messages.TestStepResult): Promise<messages.TestStepResult[]>;
53
+ runStep(pickleStep: messages.PickleStep, testStep: messages.TestStep): Promise<messages.TestStepResult>;
54
+ }
@@ -0,0 +1,268 @@
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 helpers_1 = require("./helpers");
30
+ const attachment_manager_1 = __importDefault(require("./attachment_manager"));
31
+ const step_runner_1 = __importDefault(require("./step_runner"));
32
+ const messages = __importStar(require("@cucumber/messages"));
33
+ const messages_1 = require("@cucumber/messages");
34
+ const value_checker_1 = require("../value_checker");
35
+ class TestCaseRunner {
36
+ constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, filterStackTraces, supportCodeLibrary, worldParameters, }) {
37
+ this.attachmentManager = new attachment_manager_1.default(({ data, media, fileName }) => {
38
+ if ((0, value_checker_1.doesNotHaveValue)(this.currentTestStepId)) {
39
+ throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');
40
+ }
41
+ const attachment = {
42
+ attachment: {
43
+ body: data,
44
+ contentEncoding: media.encoding,
45
+ mediaType: media.contentType,
46
+ fileName,
47
+ testCaseStartedId: this.currentTestCaseStartedId,
48
+ testStepId: this.currentTestStepId,
49
+ },
50
+ };
51
+ this.eventBroadcaster.emit('envelope', attachment);
52
+ });
53
+ this.eventBroadcaster = eventBroadcaster;
54
+ this.stopwatch = stopwatch;
55
+ this.gherkinDocument = gherkinDocument;
56
+ this.maxAttempts = 1 + (skip ? 0 : retries);
57
+ this.newId = newId;
58
+ this.pickle = pickle;
59
+ this.testCase = testCase;
60
+ this.skip = skip;
61
+ this.filterStackTraces = filterStackTraces;
62
+ this.supportCodeLibrary = supportCodeLibrary;
63
+ this.worldParameters = worldParameters;
64
+ this.resetTestProgressData();
65
+ }
66
+ resetTestProgressData() {
67
+ this.world = new this.supportCodeLibrary.World({
68
+ attach: this.attachmentManager.create.bind(this.attachmentManager),
69
+ log: this.attachmentManager.log.bind(this.attachmentManager),
70
+ parameters: this.worldParameters,
71
+ });
72
+ this.testStepResults = [];
73
+ }
74
+ getBeforeStepHookDefinitions() {
75
+ return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
76
+ }
77
+ getAfterStepHookDefinitions() {
78
+ return this.supportCodeLibrary.afterTestStepHookDefinitions
79
+ .slice(0)
80
+ .reverse()
81
+ .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
82
+ }
83
+ getWorstStepResult() {
84
+ if (this.testStepResults.length === 0) {
85
+ return {
86
+ status: this.skip
87
+ ? messages.TestStepResultStatus.SKIPPED
88
+ : messages.TestStepResultStatus.PASSED,
89
+ duration: messages.TimeConversion.millisecondsToDuration(0),
90
+ };
91
+ }
92
+ return (0, messages_1.getWorstTestStepResult)(this.testStepResults);
93
+ }
94
+ async invokeStep(step, stepDefinition, hookParameter) {
95
+ return await step_runner_1.default.run({
96
+ defaultTimeout: this.supportCodeLibrary.defaultTimeout,
97
+ filterStackTraces: this.filterStackTraces,
98
+ hookParameter,
99
+ step,
100
+ stepDefinition,
101
+ world: this.world,
102
+ });
103
+ }
104
+ isSkippingSteps() {
105
+ return (this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED);
106
+ }
107
+ shouldSkipHook(isBeforeHook) {
108
+ return this.skip || (this.isSkippingSteps() && isBeforeHook);
109
+ }
110
+ async aroundTestStep(testStepId, runStepFn) {
111
+ const testStepStarted = {
112
+ testStepStarted: {
113
+ testCaseStartedId: this.currentTestCaseStartedId,
114
+ testStepId,
115
+ timestamp: this.stopwatch.timestamp(),
116
+ },
117
+ };
118
+ this.eventBroadcaster.emit('envelope', testStepStarted);
119
+ this.currentTestStepId = testStepId;
120
+ const testStepResult = await runStepFn();
121
+ this.currentTestStepId = null;
122
+ this.testStepResults.push(testStepResult);
123
+ const testStepFinished = {
124
+ testStepFinished: {
125
+ testCaseStartedId: this.currentTestCaseStartedId,
126
+ testStepId,
127
+ testStepResult,
128
+ timestamp: this.stopwatch.timestamp(),
129
+ },
130
+ };
131
+ this.eventBroadcaster.emit('envelope', testStepFinished);
132
+ }
133
+ async run() {
134
+ for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
135
+ const moreAttemptsRemaining = attempt + 1 < this.maxAttempts;
136
+ const willBeRetried = await this.runAttempt(attempt, moreAttemptsRemaining);
137
+ if (!willBeRetried) {
138
+ break;
139
+ }
140
+ this.resetTestProgressData();
141
+ }
142
+ return this.getWorstStepResult().status;
143
+ }
144
+ async runAttempt(attempt, moreAttemptsRemaining) {
145
+ this.currentTestCaseStartedId = this.newId();
146
+ const testCaseStarted = {
147
+ testCaseStarted: {
148
+ attempt,
149
+ testCaseId: this.testCase.id,
150
+ id: this.currentTestCaseStartedId,
151
+ timestamp: this.stopwatch.timestamp(),
152
+ },
153
+ };
154
+ this.eventBroadcaster.emit('envelope', testCaseStarted);
155
+ // used to determine whether a hook is a Before or After
156
+ let didWeRunStepsYet = false;
157
+ for (const testStep of this.testCase.testSteps) {
158
+ await this.aroundTestStep(testStep.id, async () => {
159
+ if ((0, value_checker_1.doesHaveValue)(testStep.hookId)) {
160
+ const hookParameter = {
161
+ gherkinDocument: this.gherkinDocument,
162
+ pickle: this.pickle,
163
+ testCaseStartedId: this.currentTestCaseStartedId,
164
+ };
165
+ if (didWeRunStepsYet) {
166
+ hookParameter.result = this.getWorstStepResult();
167
+ hookParameter.willBeRetried =
168
+ this.getWorstStepResult().status ===
169
+ messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
170
+ }
171
+ return await this.runHook(findHookDefinition(testStep.hookId, this.supportCodeLibrary), hookParameter, !didWeRunStepsYet);
172
+ }
173
+ else {
174
+ const pickleStep = this.pickle.steps.find((pickleStep) => pickleStep.id === testStep.pickleStepId);
175
+ const testStepResult = await this.runStep(pickleStep, testStep);
176
+ didWeRunStepsYet = true;
177
+ return testStepResult;
178
+ }
179
+ });
180
+ }
181
+ const willBeRetried = this.getWorstStepResult().status ===
182
+ messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
183
+ const testCaseFinished = {
184
+ testCaseFinished: {
185
+ testCaseStartedId: this.currentTestCaseStartedId,
186
+ timestamp: this.stopwatch.timestamp(),
187
+ willBeRetried,
188
+ },
189
+ };
190
+ this.eventBroadcaster.emit('envelope', testCaseFinished);
191
+ return willBeRetried;
192
+ }
193
+ async runHook(hookDefinition, hookParameter, isBeforeHook) {
194
+ if (this.shouldSkipHook(isBeforeHook)) {
195
+ return {
196
+ status: messages.TestStepResultStatus.SKIPPED,
197
+ duration: messages.TimeConversion.millisecondsToDuration(0),
198
+ };
199
+ }
200
+ return await this.invokeStep(null, hookDefinition, hookParameter);
201
+ }
202
+ async runStepHooks(stepHooks, pickleStep, stepResult) {
203
+ const stepHooksResult = [];
204
+ const hookParameter = {
205
+ gherkinDocument: this.gherkinDocument,
206
+ pickle: this.pickle,
207
+ pickleStep,
208
+ testCaseStartedId: this.currentTestCaseStartedId,
209
+ testStepId: this.currentTestStepId,
210
+ result: stepResult,
211
+ };
212
+ for (const stepHookDefinition of stepHooks) {
213
+ stepHooksResult.push(await this.invokeStep(null, stepHookDefinition, hookParameter));
214
+ }
215
+ return stepHooksResult;
216
+ }
217
+ async runStep(pickleStep, testStep) {
218
+ const stepDefinitions = testStep.stepDefinitionIds.map((stepDefinitionId) => {
219
+ return findStepDefinition(stepDefinitionId, this.supportCodeLibrary);
220
+ });
221
+ if (stepDefinitions.length === 0) {
222
+ return {
223
+ status: messages.TestStepResultStatus.UNDEFINED,
224
+ duration: messages.TimeConversion.millisecondsToDuration(0),
225
+ };
226
+ }
227
+ else if (stepDefinitions.length > 1) {
228
+ return {
229
+ message: (0, helpers_1.getAmbiguousStepException)(stepDefinitions),
230
+ status: messages.TestStepResultStatus.AMBIGUOUS,
231
+ duration: messages.TimeConversion.millisecondsToDuration(0),
232
+ };
233
+ }
234
+ else if (this.isSkippingSteps()) {
235
+ return {
236
+ status: messages.TestStepResultStatus.SKIPPED,
237
+ duration: messages.TimeConversion.millisecondsToDuration(0),
238
+ };
239
+ }
240
+ let stepResult;
241
+ let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions(), pickleStep);
242
+ if ((0, messages_1.getWorstTestStepResult)(stepResults).status !==
243
+ messages.TestStepResultStatus.FAILED) {
244
+ stepResult = await this.invokeStep(pickleStep, stepDefinitions[0]);
245
+ stepResults.push(stepResult);
246
+ }
247
+ const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), pickleStep, stepResult);
248
+ stepResults = stepResults.concat(afterStepHookResults);
249
+ const finalStepResult = (0, messages_1.getWorstTestStepResult)(stepResults);
250
+ let finalDuration = messages.TimeConversion.millisecondsToDuration(0);
251
+ for (const result of stepResults) {
252
+ finalDuration = messages.TimeConversion.addDurations(finalDuration, result.duration);
253
+ }
254
+ finalStepResult.duration = finalDuration;
255
+ return finalStepResult;
256
+ }
257
+ }
258
+ exports.default = TestCaseRunner;
259
+ function findHookDefinition(id, supportCodeLibrary) {
260
+ return [
261
+ ...supportCodeLibrary.beforeTestCaseHookDefinitions,
262
+ ...supportCodeLibrary.afterTestCaseHookDefinitions,
263
+ ].find((definition) => definition.id === id);
264
+ }
265
+ function findStepDefinition(id, supportCodeLibrary) {
266
+ return supportCodeLibrary.stepDefinitions.find((definition) => definition.id === id);
267
+ }
268
+ //# sourceMappingURL=test_case_runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAkBlE,MAAqB,cAAc;IAkBjC,YAAY,EACV,gBAAgB,EAChB,SA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AsB,EAAC,WAAW,CAAC,CAAA;QAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAlUD,iCAkUC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { IStopwatch } from './stopwatch'\nimport StepDefinition from '../models/step_definition'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: IStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: IStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(\n ({ data, media, fileName }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n fileName,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n }\n )\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import * as messages from '@cucumber/messages';
2
+ export interface IPickleStepArgumentFunctionMap<T> {
3
+ dataTable: (arg: messages.PickleTable) => T;
4
+ docString: (arg: messages.PickleDocString) => T;
5
+ }
6
+ export declare function parseStepArgument<T>(arg: messages.PickleStepArgument, mapping: IPickleStepArgumentFunctionMap<T>): T;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseStepArgument = void 0;
7
+ const util_1 = __importDefault(require("util"));
8
+ const value_checker_1 = require("./value_checker");
9
+ function parseStepArgument(arg, mapping) {
10
+ if ((0, value_checker_1.doesHaveValue)(arg.dataTable)) {
11
+ return mapping.dataTable(arg.dataTable);
12
+ }
13
+ else if ((0, value_checker_1.doesHaveValue)(arg.docString)) {
14
+ return mapping.docString(arg.docString);
15
+ }
16
+ throw new Error(`Unknown step argument: ${util_1.default.inspect(arg)}`);
17
+ }
18
+ exports.parseStepArgument = parseStepArgument;
19
+ //# sourceMappingURL=step_arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step_arguments.js","sourceRoot":"","sources":["../src/step_arguments.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,mDAA+C;AAO/C,SAAgB,iBAAiB,CAC/B,GAAgC,EAChC,OAA0C;IAE1C,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QAChC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;KACxC;SAAM,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QACvC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;KACxC;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAChE,CAAC;AAVD,8CAUC","sourcesContent":["import util from 'util'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue } from './value_checker'\n\nexport interface IPickleStepArgumentFunctionMap<T> {\n dataTable: (arg: messages.PickleTable) => T\n docString: (arg: messages.PickleDocString) => T\n}\n\nexport function parseStepArgument<T>(\n arg: messages.PickleStepArgument,\n mapping: IPickleStepArgumentFunctionMap<T>\n): T {\n if (doesHaveValue(arg.dataTable)) {\n return mapping.dataTable(arg.dataTable)\n } else if (doesHaveValue(arg.docString)) {\n return mapping.docString(arg.docString)\n }\n throw new Error(`Unknown step argument: ${util.inspect(arg)}`)\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { ParameterType } from '@cucumber/cucumber-expressions';
2
+ import { IParameterTypeDefinition } from './types';
3
+ export declare function buildParameterType({ name, regexp, transformer, useForSnippets, preferForRegexpMatch, }: IParameterTypeDefinition<any>): ParameterType<any>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildParameterType = void 0;
4
+ const cucumber_expressions_1 = require("@cucumber/cucumber-expressions");
5
+ function buildParameterType({ name, regexp, transformer, useForSnippets, preferForRegexpMatch, }) {
6
+ if (typeof useForSnippets !== 'boolean')
7
+ useForSnippets = true;
8
+ if (typeof preferForRegexpMatch !== 'boolean')
9
+ preferForRegexpMatch = false;
10
+ return new cucumber_expressions_1.ParameterType(name, regexp, null, transformer, useForSnippets, preferForRegexpMatch);
11
+ }
12
+ exports.buildParameterType = buildParameterType;
13
+ //# sourceMappingURL=build_parameter_type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build_parameter_type.js","sourceRoot":"","sources":["../../src/support_code_library_builder/build_parameter_type.ts"],"names":[],"mappings":";;;AAAA,yEAA8D;AAG9D,SAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,WAAW,EACX,cAAc,EACd,oBAAoB,GACU;IAC9B,IAAI,OAAO,cAAc,KAAK,SAAS;QAAE,cAAc,GAAG,IAAI,CAAA;IAC9D,IAAI,OAAO,oBAAoB,KAAK,SAAS;QAAE,oBAAoB,GAAG,KAAK,CAAA;IAC3E,OAAO,IAAI,oCAAa,CACtB,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,WAAW,EACX,cAAc,EACd,oBAAoB,CACrB,CAAA;AACH,CAAC;AAjBD,gDAiBC","sourcesContent":["import { ParameterType } from '@cucumber/cucumber-expressions'\nimport { IParameterTypeDefinition } from './types'\n\nexport function buildParameterType({\n name,\n regexp,\n transformer,\n useForSnippets,\n preferForRegexpMatch,\n}: IParameterTypeDefinition<any>): ParameterType<any> {\n if (typeof useForSnippets !== 'boolean') useForSnippets = true\n if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false\n return new ParameterType(\n name,\n regexp,\n null,\n transformer,\n useForSnippets,\n preferForRegexpMatch\n )\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { isFileNameInCucumber } from '../filter_stack_trace';
2
+ import { ILineAndUri } from '../types';
3
+ export declare function getDefinitionLineAndUri(cwd: string, isExcluded?: typeof isFileNameInCucumber): ILineAndUri;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDefinitionLineAndUri = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
9
+ const filter_stack_trace_1 = require("../filter_stack_trace");
10
+ const value_checker_1 = require("../value_checker");
11
+ function getDefinitionLineAndUri(cwd, isExcluded = filter_stack_trace_1.isFileNameInCucumber) {
12
+ let line;
13
+ let uri;
14
+ const stackframes = error_stack_parser_1.default.parse(new Error());
15
+ const stackframe = stackframes.find((frame) => frame.fileName !== __filename && !isExcluded(frame.fileName));
16
+ if (stackframe != null) {
17
+ line = stackframe.getLineNumber();
18
+ uri = stackframe.getFileName();
19
+ if ((0, value_checker_1.doesHaveValue)(uri)) {
20
+ uri = path_1.default.relative(cwd, uri);
21
+ }
22
+ }
23
+ return {
24
+ line: (0, value_checker_1.valueOrDefault)(line, 0),
25
+ uri: (0, value_checker_1.valueOrDefault)(uri, 'unknown'),
26
+ };
27
+ }
28
+ exports.getDefinitionLineAndUri = getDefinitionLineAndUri;
29
+ //# sourceMappingURL=get_definition_line_and_uri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get_definition_line_and_uri.js","sourceRoot":"","sources":["../../src/support_code_library_builder/get_definition_line_and_uri.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,4EAAiE;AACjE,8DAA4D;AAC5D,oDAAgE;AAGhE,SAAgB,uBAAuB,CACrC,GAAW,EACX,UAAU,GAAG,yCAAoB;IAEjC,IAAI,IAAY,CAAA;IAChB,IAAI,GAAW,CAAA;IACf,MAAM,WAAW,GAAiB,4BAAgB,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;IACrE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CACjC,CAAC,KAAiB,EAAE,EAAE,CACpB,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC/D,CAAA;IACD,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,IAAI,GAAG,UAAU,CAAC,aAAa,EAAE,CAAA;QACjC,GAAG,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;QAC9B,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;YACtB,GAAG,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAC9B;KACF;IAED,OAAO;QACL,IAAI,EAAE,IAAA,8BAAc,EAAC,IAAI,EAAE,CAAC,CAAC;QAC7B,GAAG,EAAE,IAAA,8BAAc,EAAC,GAAG,EAAE,SAAS,CAAC;KACpC,CAAA;AACH,CAAC;AAvBD,0DAuBC","sourcesContent":["import path from 'path'\nimport errorStackParser, { StackFrame } from 'error-stack-parser'\nimport { isFileNameInCucumber } from '../filter_stack_trace'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { ILineAndUri } from '../types'\n\nexport function getDefinitionLineAndUri(\n cwd: string,\n isExcluded = isFileNameInCucumber\n): ILineAndUri {\n let line: number\n let uri: string\n const stackframes: StackFrame[] = errorStackParser.parse(new Error())\n const stackframe = stackframes.find(\n (frame: StackFrame) =>\n frame.fileName !== __filename && !isExcluded(frame.fileName)\n )\n if (stackframe != null) {\n line = stackframe.getLineNumber()\n uri = stackframe.getFileName()\n if (doesHaveValue(uri)) {\n uri = path.relative(cwd, uri)\n }\n }\n\n return {\n line: valueOrDefault(line, 0),\n uri: valueOrDefault(uri, 'unknown'),\n }\n}\n"]}