@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,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const optionsValidation = {
4
+ expectedType: 'object or function',
5
+ predicate({ options }) {
6
+ return typeof options === 'object';
7
+ },
8
+ };
9
+ const optionsTimeoutValidation = {
10
+ identifier: '"options.timeout"',
11
+ expectedType: 'integer',
12
+ predicate({ options }) {
13
+ return options.timeout == null || typeof options.timeout === 'number';
14
+ },
15
+ };
16
+ const fnValidation = {
17
+ expectedType: 'function',
18
+ predicate({ code }) {
19
+ return typeof code === 'function';
20
+ },
21
+ };
22
+ const validations = {
23
+ defineTestRunHook: [
24
+ { identifier: 'first argument', ...optionsValidation },
25
+ optionsTimeoutValidation,
26
+ { identifier: 'second argument', ...fnValidation },
27
+ ],
28
+ defineTestCaseHook: [
29
+ { identifier: 'first argument', ...optionsValidation },
30
+ {
31
+ identifier: '"options.tags"',
32
+ expectedType: 'string',
33
+ predicate({ options }) {
34
+ return options.tags == null || typeof options.tags === 'string';
35
+ },
36
+ },
37
+ optionsTimeoutValidation,
38
+ { identifier: 'second argument', ...fnValidation },
39
+ ],
40
+ defineTestStepHook: [
41
+ { identifier: 'first argument', ...optionsValidation },
42
+ {
43
+ identifier: '"options.tags"',
44
+ expectedType: 'string',
45
+ predicate({ options }) {
46
+ return options.tags == null || typeof options.tags === 'string';
47
+ },
48
+ },
49
+ optionsTimeoutValidation,
50
+ { identifier: 'second argument', ...fnValidation },
51
+ ],
52
+ defineStep: [
53
+ {
54
+ identifier: 'first argument',
55
+ expectedType: 'string or regular expression',
56
+ predicate({ pattern }) {
57
+ return pattern instanceof RegExp || typeof pattern === 'string';
58
+ },
59
+ },
60
+ { identifier: 'second argument', ...optionsValidation },
61
+ optionsTimeoutValidation,
62
+ { identifier: 'third argument', ...fnValidation },
63
+ ],
64
+ };
65
+ function validateArguments({ args, fnName, location, }) {
66
+ validations[fnName].forEach(({ identifier, expectedType, predicate }) => {
67
+ if (!predicate(args)) {
68
+ throw new Error(`${location}: Invalid ${identifier}: should be a ${expectedType}`);
69
+ }
70
+ });
71
+ }
72
+ exports.default = validateArguments;
73
+ //# sourceMappingURL=validate_arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate_arguments.js","sourceRoot":"","sources":["../../src/support_code_library_builder/validate_arguments.ts"],"names":[],"mappings":";;AAcA,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,oBAAoB;IAClC,SAAS,CAAC,EAAE,OAAO,EAAwB;QACzC,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAA;IACpC,CAAC;CACF,CAAA;AAED,MAAM,wBAAwB,GAAG;IAC/B,UAAU,EAAE,mBAAmB;IAC/B,YAAY,EAAE,SAAS;IACvB,SAAS,CAAC,EAAE,OAAO,EAAwB;QACzC,OAAO,OAAO,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAA;IACvE,CAAC;CACF,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,UAAU;IACxB,SAAS,CAAC,EAAE,IAAI,EAAwB;QACtC,OAAO,OAAO,IAAI,KAAK,UAAU,CAAA;IACnC,CAAC;CACF,CAAA;AAED,MAAM,WAAW,GAAkC;IACjD,iBAAiB,EAAE;QACjB,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,EAAE;QACtD,wBAAwB;QACxB,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,YAAY,EAAE;KACnD;IACD,kBAAkB,EAAE;QAClB,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,EAAE;QACtD;YACE,UAAU,EAAE,gBAAgB;YAC5B,YAAY,EAAE,QAAQ;YACtB,SAAS,CAAC,EAAE,OAAO,EAAE;gBACnB,OAAO,OAAO,CAAC,I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":["import { DefineStepPattern, IDefineStepOptions } from './types'\n\ninterface IValidation {\n identifier: string\n expectedType: string\n predicate: (args: any) => boolean\n}\n\ninterface IDefineStepArguments {\n pattern?: DefineStepPattern\n options?: IDefineStepOptions\n code?: Function\n}\n\nconst optionsValidation = {\n expectedType: 'object or function',\n predicate({ options }: IDefineStepArguments) {\n return typeof options === 'object'\n },\n}\n\nconst optionsTimeoutValidation = {\n identifier: '\"options.timeout\"',\n expectedType: 'integer',\n predicate({ options }: IDefineStepArguments) {\n return options.timeout == null || typeof options.timeout === 'number'\n },\n}\n\nconst fnValidation = {\n expectedType: 'function',\n predicate({ code }: IDefineStepArguments) {\n return typeof code === 'function'\n },\n}\n\nconst validations: Record<string, IValidation[]> = {\n defineTestRunHook: [\n { identifier: 'first argument', ...optionsValidation },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineTestCaseHook: [\n { identifier: 'first argument', ...optionsValidation },\n {\n identifier: '\"options.tags\"',\n expectedType: 'string',\n predicate({ options }) {\n return options.tags == null || typeof options.tags === 'string'\n },\n },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineTestStepHook: [\n { identifier: 'first argument', ...optionsValidation },\n {\n identifier: '\"options.tags\"',\n expectedType: 'string',\n predicate({ options }) {\n return options.tags == null || typeof options.tags === 'string'\n },\n },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineStep: [\n {\n identifier: 'first argument',\n expectedType: 'string or regular expression',\n predicate({ pattern }) {\n return pattern instanceof RegExp || typeof pattern === 'string'\n },\n },\n { identifier: 'second argument', ...optionsValidation },\n optionsTimeoutValidation,\n { identifier: 'third argument', ...fnValidation },\n ],\n}\n\nexport default function validateArguments({\n args,\n fnName,\n location,\n}: {\n args?: IDefineStepArguments\n fnName: string\n location: string\n}): void {\n validations[fnName].forEach(({ identifier, expectedType, predicate }) => {\n if (!predicate(args)) {\n throw new Error(\n `${location}: Invalid ${identifier}: should be a ${expectedType}`\n )\n }\n })\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { ICreateAttachment, ICreateLog } from '../runtime/attachment_manager';
2
+ export interface IWorldOptions<ParametersType = any> {
3
+ attach: ICreateAttachment;
4
+ log: ICreateLog;
5
+ parameters: ParametersType;
6
+ }
7
+ export interface IWorld<ParametersType = any> {
8
+ readonly attach: ICreateAttachment;
9
+ readonly log: ICreateLog;
10
+ readonly parameters: ParametersType;
11
+ [key: string]: any;
12
+ }
13
+ export default class World<ParametersType = any> implements IWorld<ParametersType> {
14
+ readonly attach: ICreateAttachment;
15
+ readonly log: ICreateLog;
16
+ readonly parameters: ParametersType;
17
+ constructor({ attach, log, parameters }: IWorldOptions<ParametersType>);
18
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class World {
4
+ constructor({ attach, log, parameters }) {
5
+ this.attach = attach;
6
+ this.log = log;
7
+ this.parameters = parameters;
8
+ }
9
+ }
10
+ exports.default = World;
11
+ //# sourceMappingURL=world.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/support_code_library_builder/world.ts"],"names":[],"mappings":";;AAgBA,MAAqB,KAAK;IAOxB,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAiC;QACpE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAZD,wBAYC","sourcesContent":["import { ICreateAttachment, ICreateLog } from '../runtime/attachment_manager'\n\nexport interface IWorldOptions<ParametersType = any> {\n attach: ICreateAttachment\n log: ICreateLog\n parameters: ParametersType\n}\n\nexport interface IWorld<ParametersType = any> {\n readonly attach: ICreateAttachment\n readonly log: ICreateLog\n readonly parameters: ParametersType\n\n [key: string]: any\n}\n\nexport default class World<ParametersType = any>\n implements IWorld<ParametersType>\n{\n public readonly attach: ICreateAttachment\n public readonly log: ICreateLog\n public readonly parameters: ParametersType\n\n constructor({ attach, log, parameters }: IWorldOptions<ParametersType>) {\n this.attach = attach\n this.log = log\n this.parameters = parameters\n }\n}\n"]}
package/lib/time.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { performance } from 'perf_hooks';
4
+ import * as messages from '@cucumber/messages';
5
+ interface ProtectedTimingBuiltins {
6
+ clearImmediate: typeof clearImmediate;
7
+ clearInterval: typeof clearInterval;
8
+ clearTimeout: typeof clearTimeout;
9
+ Date: typeof Date;
10
+ setImmediate: typeof setImmediate;
11
+ setInterval: typeof setInterval;
12
+ setTimeout: typeof setTimeout;
13
+ performance: typeof performance;
14
+ }
15
+ declare const methods: Partial<ProtectedTimingBuiltins>;
16
+ export declare function durationBetweenTimestamps(startedTimestamp: messages.Timestamp, finishedTimestamp: messages.Timestamp): messages.Duration;
17
+ export declare function wrapPromiseWithTimeout<T>(promise: Promise<T>, timeoutInMilliseconds: number, timeoutMessage?: string): Promise<T>;
18
+ export default methods;
package/lib/time.js ADDED
@@ -0,0 +1,61 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.wrapPromiseWithTimeout = exports.durationBetweenTimestamps = void 0;
27
+ const perf_hooks_1 = require("perf_hooks");
28
+ const messages = __importStar(require("@cucumber/messages"));
29
+ const methods = {
30
+ clearInterval: clearInterval.bind(global),
31
+ clearTimeout: clearTimeout.bind(global),
32
+ Date,
33
+ setInterval: setInterval.bind(global),
34
+ setTimeout: setTimeout.bind(global),
35
+ performance: perf_hooks_1.performance,
36
+ };
37
+ if (typeof setImmediate !== 'undefined') {
38
+ methods.setImmediate = setImmediate.bind(global);
39
+ methods.clearImmediate = clearImmediate.bind(global);
40
+ }
41
+ function durationBetweenTimestamps(startedTimestamp, finishedTimestamp) {
42
+ const durationMillis = messages.TimeConversion.timestampToMillisecondsSinceEpoch(finishedTimestamp) -
43
+ messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp);
44
+ return messages.TimeConversion.millisecondsToDuration(durationMillis);
45
+ }
46
+ exports.durationBetweenTimestamps = durationBetweenTimestamps;
47
+ async function wrapPromiseWithTimeout(promise, timeoutInMilliseconds, timeoutMessage = '') {
48
+ let timeoutId;
49
+ if (timeoutMessage === '') {
50
+ timeoutMessage = `Action did not complete within ${timeoutInMilliseconds} milliseconds`;
51
+ }
52
+ const timeoutPromise = new Promise((resolve, reject) => {
53
+ timeoutId = methods.setTimeout(() => {
54
+ reject(new Error(timeoutMessage));
55
+ }, timeoutInMilliseconds);
56
+ });
57
+ return await Promise.race([promise, timeoutPromise]).finally(() => methods.clearTimeout(timeoutId));
58
+ }
59
+ exports.wrapPromiseWithTimeout = wrapPromiseWithTimeout;
60
+ exports.default = methods;
61
+ //# sourceMappingURL=time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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CAAC,cAAc,CAAC,CAAC,CAAA;QACnC,CAAC,EAAE,qBAAqB,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAChE,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAChC,CAAA;AACH,CAAC;AAjBD,wDAiBC;AAED,kBAAe,OAAO,CAAA","sourcesContent":["import { performance } from 'perf_hooks'\nimport * as messages from '@cucumber/messages'\n\ninterface ProtectedTimingBuiltins {\n clearImmediate: typeof clearImmediate\n clearInterval: typeof clearInterval\n clearTimeout: typeof clearTimeout\n Date: typeof Date\n setImmediate: typeof setImmediate\n setInterval: typeof setInterval\n setTimeout: typeof setTimeout\n performance: typeof performance\n}\n\nconst methods: Partial<ProtectedTimingBuiltins> = {\n clearInterval: clearInterval.bind(global),\n clearTimeout: clearTimeout.bind(global),\n Date,\n setInterval: setInterval.bind(global),\n setTimeout: setTimeout.bind(global),\n performance,\n}\n\nif (typeof setImmediate !== 'undefined') {\n methods.setImmediate = setImmediate.bind(global)\n methods.clearImmediate = clearImmediate.bind(global)\n}\n\nexport function durationBetweenTimestamps(\n startedTimestamp: messages.Timestamp,\n finishedTimestamp: messages.Timestamp\n): messages.Duration {\n const durationMillis =\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(\n finishedTimestamp\n ) -\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp)\n return messages.TimeConversion.millisecondsToDuration(durationMillis)\n}\n\nexport async function wrapPromiseWithTimeout<T>(\n promise: Promise<T>,\n timeoutInMilliseconds: number,\n timeoutMessage: string = ''\n): Promise<T> {\n let timeoutId: ReturnType<typeof setTimeout>\n if (timeoutMessage === '') {\n timeoutMessage = `Action did not complete within ${timeoutInMilliseconds} milliseconds`\n }\n const timeoutPromise = new Promise<T>((resolve, reject) => {\n timeoutId = methods.setTimeout(() => {\n reject(new Error(timeoutMessage))\n }, timeoutInMilliseconds)\n })\n return await Promise.race([promise, timeoutPromise]).finally(() =>\n methods.clearTimeout(timeoutId)\n )\n}\n\nexport default methods\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Provides a try guarded require call that will throw a more detailed error when
3
+ * the ERR_REQUIRE_ESM error code is encountered.
4
+ *
5
+ * @param {string} path File path to require from.
6
+ */
7
+ export default function tryRequire(path: string): any;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Provides a try guarded require call that will throw a more detailed error when
5
+ * the ERR_REQUIRE_ESM error code is encountered.
6
+ *
7
+ * @param {string} path File path to require from.
8
+ */
9
+ function tryRequire(path) {
10
+ try {
11
+ return require(path);
12
+ }
13
+ catch (error) {
14
+ if (error.code === 'ERR_REQUIRE_ESM') {
15
+ throw Error(`Cucumber expected a CommonJS module at '${path}' but found an ES module.
16
+ Either change the file to CommonJS syntax or use the --import directive instead of --require.
17
+
18
+ Original error message: ${error.message}`);
19
+ }
20
+ else {
21
+ throw error;
22
+ }
23
+ }
24
+ }
25
+ exports.default = tryRequire;
26
+ //# sourceMappingURL=try_require.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try_require.js","sourceRoot":"","sources":["../src/try_require.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,UAAU,CAAC,IAAY;IAC7C,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACpC,MAAM,KAAK,CACT,2CAA2C,IAAI;;;gCAGvB,KAAK,CAAC,OAAO,EAAE,CACxC,CAAA;SACF;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC;AAfD,6BAeC","sourcesContent":["/**\n * Provides a try guarded require call that will throw a more detailed error when\n * the ERR_REQUIRE_ESM error code is encountered.\n *\n * @param {string} path File path to require from.\n */\nexport default function tryRequire(path: string) {\n try {\n return require(path)\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n throw Error(\n `Cucumber expected a CommonJS module at '${path}' but found an ES module.\n Either change the file to CommonJS syntax or use the --import directive instead of --require.\n \n Original error message: ${error.message}`\n )\n } else {\n throw error\n }\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export interface ILineAndUri {
2
+ line: number;
3
+ uri: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["export interface ILineAndUri {\n line: number\n uri: string\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import UncaughtExceptionListener = NodeJS.UncaughtExceptionListener;
3
+ declare const UncaughtExceptionManager: {
4
+ registerHandler(handler: UncaughtExceptionListener): void;
5
+ unregisterHandler(handler: UncaughtExceptionListener): void;
6
+ };
7
+ export default UncaughtExceptionManager;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const UncaughtExceptionManager = {
4
+ registerHandler(handler) {
5
+ process.addListener('uncaughtException', handler);
6
+ },
7
+ unregisterHandler(handler) {
8
+ process.removeListener('uncaughtException', handler);
9
+ },
10
+ };
11
+ exports.default = UncaughtExceptionManager;
12
+ //# sourceMappingURL=uncaught_exception_manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncaught_exception_manager.js","sourceRoot":"","sources":["../src/uncaught_exception_manager.ts"],"names":[],"mappings":";;AAEA,MAAM,wBAAwB,GAAG;IAC/B,eAAe,CAAC,OAAkC;QAChD,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAED,iBAAiB,CAAC,OAAkC;QAClD,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;CACF,CAAA;AAED,kBAAe,wBAAwB,CAAA","sourcesContent":["import UncaughtExceptionListener = NodeJS.UncaughtExceptionListener\n\nconst UncaughtExceptionManager = {\n registerHandler(handler: UncaughtExceptionListener): void {\n process.addListener('uncaughtException', handler)\n },\n\n unregisterHandler(handler: UncaughtExceptionListener): void {\n process.removeListener('uncaughtException', handler)\n },\n}\n\nexport default UncaughtExceptionManager\n"]}
@@ -0,0 +1,14 @@
1
+ export interface IRunRequest {
2
+ argsArray: any[];
3
+ thisArg: any;
4
+ fn: Function;
5
+ timeoutInMilliseconds: number;
6
+ }
7
+ export interface IRunResponse {
8
+ error?: any;
9
+ result?: any;
10
+ }
11
+ declare const UserCodeRunner: {
12
+ run({ argsArray, thisArg, fn, timeoutInMilliseconds, }: IRunRequest): Promise<IRunResponse>;
13
+ };
14
+ export default UserCodeRunner;
@@ -0,0 +1,82 @@
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 time_1 = require("./time");
7
+ const uncaught_exception_manager_1 = __importDefault(require("./uncaught_exception_manager"));
8
+ const util_1 = __importDefault(require("util"));
9
+ const value_checker_1 = require("./value_checker");
10
+ const UserCodeRunner = {
11
+ async run({ argsArray, thisArg, fn, timeoutInMilliseconds, }) {
12
+ const callbackPromise = new Promise((resolve, reject) => {
13
+ argsArray.push((error, result) => {
14
+ if ((0, value_checker_1.doesHaveValue)(error)) {
15
+ reject(error);
16
+ }
17
+ else {
18
+ resolve(result);
19
+ }
20
+ });
21
+ });
22
+ let fnReturn;
23
+ try {
24
+ fnReturn = fn.apply(thisArg, argsArray);
25
+ }
26
+ catch (e) {
27
+ const error = e instanceof Error ? e : util_1.default.format(e);
28
+ return { error };
29
+ }
30
+ const racingPromises = [];
31
+ const callbackInterface = fn.length === argsArray.length;
32
+ const promiseInterface = (0, value_checker_1.doesHaveValue)(fnReturn) && typeof fnReturn.then === 'function';
33
+ if (callbackInterface && promiseInterface) {
34
+ return {
35
+ error: new Error('function uses multiple asynchronous interfaces: callback and promise\n' +
36
+ 'to use the callback interface: do not return a promise\n' +
37
+ 'to use the promise interface: remove the last argument to the function'),
38
+ };
39
+ }
40
+ else if (callbackInterface) {
41
+ racingPromises.push(callbackPromise);
42
+ }
43
+ else if (promiseInterface) {
44
+ racingPromises.push(fnReturn);
45
+ }
46
+ else {
47
+ return { result: fnReturn };
48
+ }
49
+ let exceptionHandler;
50
+ const uncaughtExceptionPromise = new Promise((resolve, reject) => {
51
+ exceptionHandler = reject;
52
+ uncaught_exception_manager_1.default.registerHandler(exceptionHandler);
53
+ });
54
+ racingPromises.push(uncaughtExceptionPromise);
55
+ let finalPromise = Promise.race(racingPromises);
56
+ if (timeoutInMilliseconds >= 0) {
57
+ const timeoutMessage = 'function timed out, ensure the ' +
58
+ (callbackInterface ? 'callback is executed' : 'promise resolves') +
59
+ ` within ${timeoutInMilliseconds.toString()} milliseconds`;
60
+ finalPromise = (0, time_1.wrapPromiseWithTimeout)(finalPromise, timeoutInMilliseconds, timeoutMessage);
61
+ }
62
+ let error, result;
63
+ try {
64
+ result = await finalPromise;
65
+ }
66
+ catch (e) {
67
+ if (e instanceof Error) {
68
+ error = e;
69
+ }
70
+ else if ((0, value_checker_1.doesHaveValue)(e)) {
71
+ error = util_1.default.format(e);
72
+ }
73
+ else {
74
+ error = new Error('Promise rejected without a reason');
75
+ }
76
+ }
77
+ uncaught_exception_manager_1.default.unregisterHandler(exceptionHandler);
78
+ return { error, result };
79
+ },
80
+ };
81
+ exports.default = UserCodeRunner;
82
+ //# sourceMappingURL=user_code_runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_code_runner.js","sourceRoot":"","sources":["../src/user_code_runner.ts"],"names":[],"mappings":";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C,CAAA;QAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IAC1B,CAAC;CACF,CAAA;AAED,kBAAe,cAAc,CAAA","sourcesContent":["import { wrapPromiseWithTimeout } from './time'\nimport UncaughtExceptionManager from './uncaught_exception_manager'\nimport util from 'util'\nimport { doesHaveValue } from './value_checker'\n\nexport interface IRunRequest {\n argsArray: any[]\n thisArg: any\n fn: Function\n timeoutInMilliseconds: number\n}\n\nexport interface IRunResponse {\n error?: any\n result?: any\n}\n\nconst UserCodeRunner = {\n async run({\n argsArray,\n thisArg,\n fn,\n timeoutInMilliseconds,\n }: IRunRequest): Promise<IRunResponse> {\n const callbackPromise = new Promise((resolve, reject) => {\n argsArray.push((error: Error, result: IRunResponse) => {\n if (doesHaveValue(error)) {\n reject(error)\n } else {\n resolve(result)\n }\n })\n })\n\n let fnReturn\n try {\n fnReturn = fn.apply(thisArg, argsArray)\n } catch (e) {\n const error = e instanceof Error ? e : util.format(e)\n return { error }\n }\n\n const racingPromises = []\n const callbackInterface = fn.length === argsArray.length\n const promiseInterface =\n doesHaveValue(fnReturn) && typeof fnReturn.then === 'function'\n\n if (callbackInterface && promiseInterface) {\n return {\n error: new Error(\n 'function uses multiple asynchronous interfaces: callback and promise\\n' +\n 'to use the callback interface: do not return a promise\\n' +\n 'to use the promise interface: remove the last argument to the function'\n ),\n }\n } else if (callbackInterface) {\n racingPromises.push(callbackPromise)\n } else if (promiseInterface) {\n racingPromises.push(fnReturn)\n } else {\n return { result: fnReturn }\n }\n\n let exceptionHandler\n const uncaughtExceptionPromise = new Promise((resolve, reject) => {\n exceptionHandler = reject\n UncaughtExceptionManager.registerHandler(exceptionHandler)\n })\n racingPromises.push(uncaughtExceptionPromise)\n\n let finalPromise = Promise.race(racingPromises)\n if (timeoutInMilliseconds >= 0) {\n const timeoutMessage =\n 'function timed out, ensure the ' +\n (callbackInterface ? 'callback is executed' : 'promise resolves') +\n ` within ${timeoutInMilliseconds.toString()} milliseconds`\n finalPromise = wrapPromiseWithTimeout(\n finalPromise,\n timeoutInMilliseconds,\n timeoutMessage\n )\n }\n\n let error, result\n try {\n result = await finalPromise\n } catch (e) {\n if (e instanceof Error) {\n error = e\n } else if (doesHaveValue(e)) {\n error = util.format(e)\n } else {\n error = new Error('Promise rejected without a reason')\n }\n }\n\n UncaughtExceptionManager.unregisterHandler(exceptionHandler)\n\n return { error, result }\n },\n}\n\nexport default UserCodeRunner\n"]}
@@ -0,0 +1,3 @@
1
+ export declare function doesHaveValue<T>(value: T): boolean;
2
+ export declare function doesNotHaveValue<T>(value: T): boolean;
3
+ export declare function valueOrDefault<T>(value: T, defaultValue: T): T;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.valueOrDefault = exports.doesNotHaveValue = exports.doesHaveValue = void 0;
4
+ function doesHaveValue(value) {
5
+ return !doesNotHaveValue(value);
6
+ }
7
+ exports.doesHaveValue = doesHaveValue;
8
+ function doesNotHaveValue(value) {
9
+ return value === null || value === undefined;
10
+ }
11
+ exports.doesNotHaveValue = doesNotHaveValue;
12
+ function valueOrDefault(value, defaultValue) {
13
+ if (doesHaveValue(value)) {
14
+ return value;
15
+ }
16
+ return defaultValue;
17
+ }
18
+ exports.valueOrDefault = valueOrDefault;
19
+ //# sourceMappingURL=value_checker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value_checker.js","sourceRoot":"","sources":["../src/value_checker.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAI,KAAQ;IACvC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;AAFD,sCAEC;AAED,SAAgB,gBAAgB,CAAI,KAAQ;IAC1C,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAA;AAC9C,CAAC;AAFD,4CAEC;AAED,SAAgB,cAAc,CAAI,KAAQ,EAAE,YAAe;IACzD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAA;KACb;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AALD,wCAKC","sourcesContent":["export function doesHaveValue<T>(value: T): boolean {\n return !doesNotHaveValue(value)\n}\n\nexport function doesNotHaveValue<T>(value: T): boolean {\n return value === null || value === undefined\n}\n\nexport function valueOrDefault<T>(value: T, defaultValue: T): T {\n if (doesHaveValue(value)) {\n return value\n }\n return defaultValue\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const version = "1.0.0";
package/lib/version.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ // Generated by genversion.
5
+ exports.version = '1.0.0';
6
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.0'\n"]}
@@ -0,0 +1,44 @@
1
+ import cucumber from './index.js'
2
+
3
+ export const supportCodeLibraryBuilder = cucumber.supportCodeLibraryBuilder
4
+ export const Status = cucumber.Status
5
+ export const DataTable = cucumber.DataTable
6
+ export const TestCaseHookDefinition = cucumber.TestCaseHookDefinition
7
+ export const version = cucumber.version
8
+
9
+ export const Formatter = cucumber.Formatter
10
+ export const FormatterBuilder = cucumber.FormatterBuilder
11
+ export const JsonFormatter = cucumber.JsonFormatter
12
+ export const ProgressFormatter = cucumber.ProgressFormatter
13
+ export const RerunFormatter = cucumber.RerunFormatter
14
+ export const SnippetsFormatter = cucumber.SnippetsFormatter
15
+ export const SummaryFormatter = cucumber.SummaryFormatter
16
+ export const UsageFormatter = cucumber.UsageFormatter
17
+ export const UsageJsonFormatter = cucumber.UsageJsonFormatter
18
+ export const formatterHelpers = cucumber.formatterHelpers
19
+
20
+ export const After = cucumber.After
21
+ export const AfterAll = cucumber.AfterAll
22
+ export const AfterStep = cucumber.AfterStep
23
+ export const Before = cucumber.Before
24
+ export const BeforeAll = cucumber.BeforeAll
25
+ export const BeforeStep = cucumber.BeforeStep
26
+ export const defineStep = cucumber.defineStep
27
+ export const defineParameterType = cucumber.defineParameterType
28
+ export const Given = cucumber.Given
29
+ export const setDefaultTimeout = cucumber.setDefaultTimeout
30
+ export const setDefinitionFunctionWrapper =
31
+ cucumber.setDefinitionFunctionWrapper
32
+ export const setWorldConstructor = cucumber.setWorldConstructor
33
+ export const Then = cucumber.Then
34
+ export const When = cucumber.When
35
+ export const World = cucumber.World
36
+ export const parallelCanAssignHelpers = cucumber.parallelCanAssignHelpers
37
+
38
+ export const wrapPromiseWithTimeout = cucumber.wrapPromiseWithTimeout
39
+
40
+ // Deprecated
41
+ export const Cli = cucumber.Cli
42
+ export const parseGherkinMessageStream = cucumber.parseGherkinMessageStream
43
+ export const PickleFilter = cucumber.PickleFilter
44
+ export const Runtime = cucumber.Runtime