@cucumber/cucumber 9.6.0 → 10.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 (193) hide show
  1. package/lib/api/console_logger.d.ts +1 -1
  2. package/lib/api/console_logger.js +5 -2
  3. package/lib/api/console_logger.js.map +1 -1
  4. package/lib/api/convert_configuration.d.ts +1 -1
  5. package/lib/api/convert_configuration.js +2 -2
  6. package/lib/api/convert_configuration.js.map +1 -1
  7. package/lib/api/formatters.d.ts +2 -2
  8. package/lib/api/formatters.js +6 -6
  9. package/lib/api/formatters.js.map +1 -1
  10. package/lib/api/gherkin.d.ts +1 -1
  11. package/lib/api/gherkin.js +1 -1
  12. package/lib/api/gherkin.js.map +1 -1
  13. package/lib/api/load_configuration.js +1 -2
  14. package/lib/api/load_configuration.js.map +1 -1
  15. package/lib/api/load_sources.js +1 -1
  16. package/lib/api/load_sources.js.map +1 -1
  17. package/lib/api/load_support.d.ts +1 -1
  18. package/lib/api/load_support.js.map +1 -1
  19. package/lib/api/paths.d.ts +1 -1
  20. package/lib/api/paths.js +18 -16
  21. package/lib/api/paths.js.map +1 -1
  22. package/lib/api/plugins.d.ts +1 -1
  23. package/lib/api/plugins.js.map +1 -1
  24. package/lib/api/run_cucumber.js +2 -2
  25. package/lib/api/run_cucumber.js.map +1 -1
  26. package/lib/api/runtime.d.ts +3 -3
  27. package/lib/api/runtime.js.map +1 -1
  28. package/lib/api/support.js +2 -4
  29. package/lib/api/support.js.map +1 -1
  30. package/lib/api/test_helpers.js +8 -8
  31. package/lib/api/test_helpers.js.map +1 -1
  32. package/lib/api/types.d.ts +1 -1
  33. package/lib/api/types.js.map +1 -1
  34. package/lib/cli/helpers.d.ts +4 -4
  35. package/lib/cli/helpers.js +5 -5
  36. package/lib/cli/helpers.js.map +1 -1
  37. package/lib/cli/index.js +6 -1
  38. package/lib/cli/index.js.map +1 -1
  39. package/lib/cli/run.js +1 -1
  40. package/lib/cli/run.js.map +1 -1
  41. package/lib/cli/validate_node_engine_version.js +4 -4
  42. package/lib/cli/validate_node_engine_version.js.map +1 -1
  43. package/lib/configuration/from_file.d.ts +1 -1
  44. package/lib/configuration/from_file.js +41 -21
  45. package/lib/configuration/from_file.js.map +1 -1
  46. package/lib/configuration/locate_file.js +2 -2
  47. package/lib/configuration/locate_file.js.map +1 -1
  48. package/lib/configuration/merge_configurations.js.map +1 -1
  49. package/lib/configuration/validate_configuration.d.ts +1 -1
  50. package/lib/configuration/validate_configuration.js +3 -0
  51. package/lib/configuration/validate_configuration.js.map +1 -1
  52. package/lib/filter_stack_trace.js +4 -4
  53. package/lib/filter_stack_trace.js.map +1 -1
  54. package/lib/formatter/builder.d.ts +5 -5
  55. package/lib/formatter/builder.js +11 -24
  56. package/lib/formatter/builder.js.map +1 -1
  57. package/lib/formatter/get_color_fns.d.ts +1 -1
  58. package/lib/formatter/get_color_fns.js.map +1 -1
  59. package/lib/formatter/helpers/event_data_collector.d.ts +1 -1
  60. package/lib/formatter/helpers/event_data_collector.js +5 -5
  61. package/lib/formatter/helpers/event_data_collector.js.map +1 -1
  62. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  63. package/lib/formatter/helpers/location_helpers.js +2 -2
  64. package/lib/formatter/helpers/location_helpers.js.map +1 -1
  65. package/lib/formatter/helpers/pickle_parser.js.map +1 -1
  66. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
  67. package/lib/formatter/helpers/summary_helpers.d.ts +1 -1
  68. package/lib/formatter/helpers/summary_helpers.js +1 -1
  69. package/lib/formatter/helpers/summary_helpers.js.map +1 -1
  70. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +1 -1
  71. package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
  72. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  73. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -1
  74. package/lib/formatter/helpers/test_case_attempt_parser.js +3 -3
  75. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  76. package/lib/formatter/helpers/usage_helpers/index.js +1 -1
  77. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  78. package/lib/formatter/html_formatter.js +6 -5
  79. package/lib/formatter/html_formatter.js.map +1 -1
  80. package/lib/formatter/index.d.ts +3 -3
  81. package/lib/formatter/index.js +10 -0
  82. package/lib/formatter/index.js.map +1 -1
  83. package/lib/formatter/json_formatter.d.ts +1 -1
  84. package/lib/formatter/json_formatter.js +10 -8
  85. package/lib/formatter/json_formatter.js.map +1 -1
  86. package/lib/formatter/junit_formatter.js +11 -12
  87. package/lib/formatter/junit_formatter.js.map +1 -1
  88. package/lib/formatter/message_formatter.js +1 -1
  89. package/lib/formatter/message_formatter.js.map +1 -1
  90. package/lib/formatter/progress_bar_formatter.d.ts +1 -1
  91. package/lib/formatter/progress_bar_formatter.js +8 -4
  92. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  93. package/lib/formatter/progress_formatter.d.ts +1 -1
  94. package/lib/formatter/progress_formatter.js +3 -3
  95. package/lib/formatter/progress_formatter.js.map +1 -1
  96. package/lib/formatter/rerun_formatter.js +5 -4
  97. package/lib/formatter/rerun_formatter.js.map +1 -1
  98. package/lib/formatter/snippets_formatter.js +4 -4
  99. package/lib/formatter/snippets_formatter.js.map +1 -1
  100. package/lib/formatter/step_definition_snippet_builder/index.d.ts +2 -2
  101. package/lib/formatter/step_definition_snippet_builder/index.js +3 -1
  102. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
  103. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +1 -0
  104. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
  105. package/lib/formatter/summary_formatter.d.ts +1 -1
  106. package/lib/formatter/summary_formatter.js +4 -4
  107. package/lib/formatter/summary_formatter.js.map +1 -1
  108. package/lib/formatter/usage_formatter.js +4 -4
  109. package/lib/formatter/usage_formatter.js.map +1 -1
  110. package/lib/formatter/usage_json_formatter.js +2 -2
  111. package/lib/formatter/usage_json_formatter.js.map +1 -1
  112. package/lib/index.d.ts +1 -1
  113. package/lib/index.js +6 -6
  114. package/lib/index.js.map +1 -1
  115. package/lib/models/data_table.js +1 -0
  116. package/lib/models/data_table.js.map +1 -1
  117. package/lib/models/definition.d.ts +1 -1
  118. package/lib/models/definition.js +6 -0
  119. package/lib/models/definition.js.map +1 -1
  120. package/lib/models/step_definition.d.ts +1 -1
  121. package/lib/models/step_definition.js +5 -2
  122. package/lib/models/step_definition.js.map +1 -1
  123. package/lib/models/test_case_hook_definition.d.ts +1 -1
  124. package/lib/models/test_case_hook_definition.js +3 -0
  125. package/lib/models/test_case_hook_definition.js.map +1 -1
  126. package/lib/models/test_step_hook_definition.d.ts +1 -1
  127. package/lib/models/test_step_hook_definition.js +2 -0
  128. package/lib/models/test_step_hook_definition.js.map +1 -1
  129. package/lib/pickle_filter.js +11 -5
  130. package/lib/pickle_filter.js.map +1 -1
  131. package/lib/plugin/plugin_manager.d.ts +1 -1
  132. package/lib/plugin/plugin_manager.js +3 -2
  133. package/lib/plugin/plugin_manager.js.map +1 -1
  134. package/lib/plugin/types.d.ts +1 -1
  135. package/lib/plugin/types.js.map +1 -1
  136. package/lib/publish/http_stream.d.ts +2 -2
  137. package/lib/publish/http_stream.js +14 -9
  138. package/lib/publish/http_stream.js.map +1 -1
  139. package/lib/publish/publish_plugin.js +3 -3
  140. package/lib/publish/publish_plugin.js.map +1 -1
  141. package/lib/runtime/assemble_test_cases.d.ts +1 -1
  142. package/lib/runtime/assemble_test_cases.js.map +1 -1
  143. package/lib/runtime/attachment_manager/index.d.ts +1 -1
  144. package/lib/runtime/attachment_manager/index.js +1 -0
  145. package/lib/runtime/attachment_manager/index.js.map +1 -1
  146. package/lib/runtime/format_error.js +1 -1
  147. package/lib/runtime/format_error.js.map +1 -1
  148. package/lib/runtime/helpers.d.ts +1 -1
  149. package/lib/runtime/helpers.js +2 -2
  150. package/lib/runtime/helpers.js.map +1 -1
  151. package/lib/runtime/index.d.ts +1 -1
  152. package/lib/runtime/index.js +9 -0
  153. package/lib/runtime/index.js.map +1 -1
  154. package/lib/runtime/parallel/coordinator.d.ts +4 -4
  155. package/lib/runtime/parallel/coordinator.js +24 -5
  156. package/lib/runtime/parallel/coordinator.js.map +1 -1
  157. package/lib/runtime/parallel/run_worker.js +1 -1
  158. package/lib/runtime/parallel/run_worker.js.map +1 -1
  159. package/lib/runtime/parallel/worker.js +14 -6
  160. package/lib/runtime/parallel/worker.js.map +1 -1
  161. package/lib/runtime/run_test_run_hooks.js +1 -1
  162. package/lib/runtime/run_test_run_hooks.js.map +1 -1
  163. package/lib/runtime/step_runner.js +2 -2
  164. package/lib/runtime/step_runner.js.map +1 -1
  165. package/lib/runtime/stopwatch.js +2 -0
  166. package/lib/runtime/stopwatch.js.map +1 -1
  167. package/lib/runtime/test_case_runner.d.ts +1 -1
  168. package/lib/runtime/test_case_runner.js +19 -3
  169. package/lib/runtime/test_case_runner.js.map +1 -1
  170. package/lib/step_arguments.js +2 -2
  171. package/lib/step_arguments.js.map +1 -1
  172. package/lib/support_code_library_builder/get_definition_line_and_uri.js +2 -2
  173. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
  174. package/lib/support_code_library_builder/index.d.ts +1 -1
  175. package/lib/support_code_library_builder/index.js +24 -8
  176. package/lib/support_code_library_builder/index.js.map +1 -1
  177. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +1 -4
  178. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -1
  179. package/lib/support_code_library_builder/world.js +3 -0
  180. package/lib/support_code_library_builder/world.js.map +1 -1
  181. package/lib/time.d.ts +1 -1
  182. package/lib/time.js +2 -2
  183. package/lib/time.js.map +1 -1
  184. package/lib/user_code_runner.js +3 -3
  185. package/lib/user_code_runner.js.map +1 -1
  186. package/lib/version.d.ts +1 -1
  187. package/lib/version.js +1 -1
  188. package/lib/version.js.map +1 -1
  189. package/package.json +16 -14
  190. package/lib/formatter/fixtures/typescript.d.ts +0 -2
  191. package/lib/formatter/fixtures/typescript.js +0 -6
  192. package/lib/formatter/fixtures/typescript.js.map +0 -1
  193. package/lib/importer.js +0 -13
@@ -1,6 +1,6 @@
1
- import { Plugin, PluginEvents } from './types';
2
1
  import { IRunEnvironment, IRunOptions } from '../api';
3
2
  import { ILogger } from '../logger';
3
+ import { Plugin, PluginEvents } from './types';
4
4
  export declare class PluginManager {
5
5
  private pluginFns;
6
6
  private handlers;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PluginManager = void 0;
4
4
  class PluginManager {
5
+ pluginFns;
6
+ handlers = { message: [] };
7
+ cleanupFns = [];
5
8
  constructor(pluginFns) {
6
9
  this.pluginFns = pluginFns;
7
- this.handlers = { message: [] };
8
- this.cleanupFns = [];
9
10
  }
10
11
  async register(event, handler) {
11
12
  this.handlers[event].push(handler);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;AAQA,MAAa,aAAa;IAIxB,YAAoB,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;QAH/B,aAAQ,GAAoB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;QAC3C,eAAU,GAAoB,EAAE,CAAA;IAEE,CAAC;IAEnC,KAAK,CAAC,QAAQ,CACpB,KAAQ,EACR,OAAyC;QAEzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,IAAI,CACR,MAAe,EACf,aAA0B,EAC1B,WAA4B;QAE5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;gBAC/B,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC5B,MAAM;gBACN,aAAa;gBACb,WAAW;aACZ,CAAC,CAAA;YACF,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;aAChC;SACF;IACH,CAAC;IAED,IAAI,CAA+B,KAAQ,EAAE,KAAsB;QACjE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO;QACX,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,MAAM,SAAS,EAAE,CAAA;SAClB;IACH,CAAC;CACF;AAxCD,sCAwCC","sourcesContent":["import { Plugin, PluginCleanup, PluginEvents } from './types'\nimport { IRunEnvironment, IRunOptions } from '../api'\nimport { ILogger } from '../logger'\n\ntype HandlerRegistry = {\n [K in keyof PluginEvents]: Array<(value: PluginEvents[K]) => void>\n}\n\nexport class PluginManager {\n private handlers: HandlerRegistry = { message: [] }\n private cleanupFns: PluginCleanup[] = []\n\n constructor(private pluginFns: Plugin[]) {}\n\n private async register<K extends keyof PluginEvents>(\n event: K,\n handler: (value: PluginEvents[K]) => void\n ) {\n this.handlers[event].push(handler)\n }\n\n async init(\n logger: ILogger,\n configuration: IRunOptions,\n environment: IRunEnvironment\n ) {\n for (const pluginFn of this.pluginFns) {\n const cleanupFn = await pluginFn({\n on: this.register.bind(this),\n logger,\n configuration,\n environment,\n })\n if (cleanupFn) {\n this.cleanupFns.push(cleanupFn)\n }\n }\n }\n\n emit<K extends keyof PluginEvents>(event: K, value: PluginEvents[K]): void {\n this.handlers[event].forEach((handler) => handler(value))\n }\n\n async cleanup(): Promise<void> {\n for (const cleanupFn of this.cleanupFns) {\n await cleanupFn()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;AAQA,MAAa,aAAa;IAIJ;IAHZ,QAAQ,GAAoB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;IAC3C,UAAU,GAAoB,EAAE,CAAA;IAExC,YAAoB,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;IAAG,CAAC;IAEnC,KAAK,CAAC,QAAQ,CACpB,KAAQ,EACR,OAAyC;QAEzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,IAAI,CACR,MAAe,EACf,aAA0B,EAC1B,WAA4B;QAE5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;gBAC/B,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC5B,MAAM;gBACN,aAAa;gBACb,WAAW;aACZ,CAAC,CAAA;YACF,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;aAChC;SACF;IACH,CAAC;IAED,IAAI,CAA+B,KAAQ,EAAE,KAAsB;QACjE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO;QACX,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,MAAM,SAAS,EAAE,CAAA;SAClB;IACH,CAAC;CACF;AAxCD,sCAwCC","sourcesContent":["import { IRunEnvironment, IRunOptions } from '../api'\nimport { ILogger } from '../logger'\nimport { Plugin, PluginCleanup, PluginEvents } from './types'\n\ntype HandlerRegistry = {\n [K in keyof PluginEvents]: Array<(value: PluginEvents[K]) => void>\n}\n\nexport class PluginManager {\n private handlers: HandlerRegistry = { message: [] }\n private cleanupFns: PluginCleanup[] = []\n\n constructor(private pluginFns: Plugin[]) {}\n\n private async register<K extends keyof PluginEvents>(\n event: K,\n handler: (value: PluginEvents[K]) => void\n ) {\n this.handlers[event].push(handler)\n }\n\n async init(\n logger: ILogger,\n configuration: IRunOptions,\n environment: IRunEnvironment\n ) {\n for (const pluginFn of this.pluginFns) {\n const cleanupFn = await pluginFn({\n on: this.register.bind(this),\n logger,\n configuration,\n environment,\n })\n if (cleanupFn) {\n this.cleanupFns.push(cleanupFn)\n }\n }\n }\n\n emit<K extends keyof PluginEvents>(event: K, value: PluginEvents[K]): void {\n this.handlers[event].forEach((handler) => handler(value))\n }\n\n async cleanup(): Promise<void> {\n for (const cleanupFn of this.cleanupFns) {\n await cleanupFn()\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { IRunEnvironment, IRunOptions } from '../api';
2
1
  import { Envelope } from '@cucumber/messages';
2
+ import { IRunEnvironment, IRunOptions } from '../api';
3
3
  import { ILogger } from '../logger';
4
4
  export interface PluginEvents {
5
5
  message: Envelope;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IRunEnvironment, IRunOptions } from '../api'\nimport { Envelope } from '@cucumber/messages'\nimport { ILogger } from '../logger'\n\nexport interface PluginEvents {\n message: Envelope\n}\n\nexport interface PluginContext {\n on: <K extends keyof PluginEvents>(\n event: K,\n handler: (value: PluginEvents[K]) => void\n ) => void\n logger: ILogger\n configuration: IRunOptions\n environment: IRunEnvironment\n}\n\nexport type PluginCleanup = () => any | void | Promise<any | void>\n\nexport type Plugin = (context: PluginContext) => Promise<PluginCleanup | void>\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { IRunEnvironment, IRunOptions } from '../api'\nimport { ILogger } from '../logger'\n\nexport interface PluginEvents {\n message: Envelope\n}\n\nexport interface PluginContext {\n on: <K extends keyof PluginEvents>(\n event: K,\n handler: (value: PluginEvents[K]) => void\n ) => void\n logger: ILogger\n configuration: IRunOptions\n environment: IRunEnvironment\n}\n\nexport type PluginCleanup = () => any | void | Promise<any | void>\n\nexport type Plugin = (context: PluginContext) => Promise<PluginCleanup | void>\n"]}
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
- import { Transform } from 'stream';
5
- import http from 'http';
4
+ import { Transform } from 'node:stream';
5
+ import http from 'node:http';
6
6
  type HttpMethod = 'GET' | 'POST' | 'PUT';
7
7
  /**
8
8
  * This Writable writes data to a HTTP/HTTPS URL.
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const stream_1 = require("stream");
6
+ const node_stream_1 = require("node:stream");
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_http_1 = __importDefault(require("node:http"));
9
+ const node_https_1 = __importDefault(require("node:https"));
7
10
  const tmp_1 = __importDefault(require("tmp"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const http_1 = __importDefault(require("http"));
10
- const https_1 = __importDefault(require("https"));
11
11
  const value_checker_1 = require("../value_checker");
12
12
  /**
13
13
  * This Writable writes data to a HTTP/HTTPS URL.
@@ -19,7 +19,12 @@ const value_checker_1 = require("../value_checker");
19
19
  *
20
20
  * 3xx redirects are not currently followed.
21
21
  */
22
- class HttpStream extends stream_1.Transform {
22
+ class HttpStream extends node_stream_1.Transform {
23
+ url;
24
+ method;
25
+ headers;
26
+ tempFilePath;
27
+ tempFile;
23
28
  constructor(url, method, headers) {
24
29
  super({
25
30
  readableObjectMode: true,
@@ -34,7 +39,7 @@ class HttpStream extends stream_1.Transform {
34
39
  if ((0, value_checker_1.doesHaveValue)(err))
35
40
  return callback(err);
36
41
  this.tempFilePath = name;
37
- this.tempFile = fs_1.default.createWriteStream(name, { fd });
42
+ this.tempFile = node_fs_1.default.createWriteStream(name, { fd });
38
43
  this.tempFile.write(chunk, encoding, callback);
39
44
  });
40
45
  }
@@ -80,11 +85,11 @@ class HttpStream extends stream_1.Transform {
80
85
  this.emit('error', new Error(`Unexpected http status ${res.statusCode} from ${method} ${url}`));
81
86
  }
82
87
  sendHttpRequest(url, method, headers, callback) {
83
- const httpx = (0, value_checker_1.doesHaveValue)(url.match(/^https:/)) ? https_1.default : http_1.default;
88
+ const httpx = (0, value_checker_1.doesHaveValue)(url.match(/^https:/)) ? node_https_1.default : node_http_1.default;
84
89
  const additionalHttpHeaders = {};
85
90
  const upload = method === 'PUT' || method === 'POST';
86
91
  if (upload) {
87
- additionalHttpHeaders['Content-Length'] = fs_1.default.statSync(this.tempFilePath).size;
92
+ additionalHttpHeaders['Content-Length'] = node_fs_1.default.statSync(this.tempFilePath).size;
88
93
  }
89
94
  const allHeaders = { ...headers, ...additionalHttpHeaders };
90
95
  const req = httpx.request(url, {
@@ -97,7 +102,7 @@ class HttpStream extends stream_1.Transform {
97
102
  callback(null, res);
98
103
  });
99
104
  if (upload) {
100
- (0, stream_1.pipeline)(fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
105
+ (0, node_stream_1.pipeline)(node_fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
101
106
  if ((0, value_checker_1.doesHaveValue)(err)) {
102
107
  this.emit('error', err);
103
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/publish/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsD;AACtD,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,kBAAS;IAI/C,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,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AAG,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5D,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;oBACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;iBACxB;YACH,CAAC,CAAC,CAAA;SACH;aAAM;YACL,GAAG,CAAC,GAAG,EAAE,CAAA;SACV;IACH,CAAC;CACF;AA9HD,6BA8HC","sourcesContent":["import { pipeline, Transform, Writable } from 'stream'\nimport tmp from 'tmp'\nimport fs from 'fs'\nimport http from 'http'\nimport https from 'https'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(res2, this.url, this.method)\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/publish/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,6CAA2D;AAC3D,sDAAwB;AACxB,0DAA4B;AAC5B,4DAA8B;AAC9B,8CAAqB;AACrB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,uBAAS;IAK5B;IACA;IACA;IANX,YAAY,CAAQ;IACpB,QA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;YACV,IAAA,sBAAQ,EAAC,iBAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5D,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;oBACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;iBACxB;YACH,CAAC,CAAC,CAAA;SACH;aAAM;YACL,GAAG,CAAC,GAAG,EAAE,CAAA;SACV;IACH,CAAC;CACF;AA9HD,6BA8HC","sourcesContent":["import { pipeline, Transform, Writable } from 'node:stream'\nimport fs from 'node:fs'\nimport http from 'node:http'\nimport https from 'node:https'\nimport tmp from 'tmp'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(res2, this.url, this.method)\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.publishPlugin = void 0;
7
- const http_stream_1 = __importDefault(require("./http_stream"));
8
- const stream_1 = require("stream");
7
+ const node_stream_1 = require("node:stream");
9
8
  const supports_color_1 = require("supports-color");
10
9
  const has_ansi_1 = __importDefault(require("has-ansi"));
11
10
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
11
+ const http_stream_1 = __importDefault(require("./http_stream"));
12
12
  const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
13
13
  const publishPlugin = async ({ on, logger, configuration, environment, }) => {
14
14
  if (!configuration.formats.publish) {
@@ -20,7 +20,7 @@ const publishPlugin = async ({ on, logger, configuration, environment, }) => {
20
20
  headers.Authorization = `Bearer ${token}`;
21
21
  }
22
22
  const stream = new http_stream_1.default(url, 'GET', headers);
23
- const readerStream = new stream_1.Writable({
23
+ const readerStream = new node_stream_1.Writable({
24
24
  objectMode: true,
25
25
  write: function (responseBody, encoding, writeCallback) {
26
26
  environment.stderr.write(sanitisePublishOutput(responseBody, environment.stderr) + '\n');
@@ -1 +1 @@
1
- {"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AACA,gEAAsC;AACtC,mCAAiC;AACjC,mDAA8C;AAC9C,wDAA8B;AAC9B,4DAAkC;AAElC,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAExE,MAAM,aAAa,GAAW,KAAK,EAAE,EAC1C,EAAE,EACF,MAAM,EACN,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE;QAClC,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,EAAE,GAAG,GAAG,4BAA4B,EAAE,KAAK,EAAE,GACjD,aAAa,CAAC,OAAO,CAAC,OAAO,CAAA;IAC/B,MAAM,OAAO,GAA8B,EAAE,CAAA;IAC7C,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;KAC1C;IACD,MAAM,MAAM,GAAG,IAAI,qBAA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import { Writable } from 'stream'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport stripAnsi from 'strip-ansi'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: Plugin = async ({\n on,\n logger,\n configuration,\n environment,\n}) => {\n if (!configuration.formats.publish) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } =\n configuration.formats.publish\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n environment.stderr.write(\n sanitisePublishOutput(responseBody, environment.stderr) + '\\n'\n )\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n stream.on('error', (error: Error) => logger.error(error.message))\n on('message', (value) => stream.write(JSON.stringify(value) + '\\n'))\n return () =>\n new Promise<void>((resolve) => {\n stream.on('finish', () => resolve())\n stream.end()\n })\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripAnsi(raw)\n }\n return raw\n}\n"]}
1
+ {"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,mDAA8C;AAC9C,wDAA8B;AAC9B,4DAAkC;AAElC,gEAAsC;AAEtC,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAExE,MAAM,aAAa,GAAW,KAAK,EAAE,EAC1C,EAAE,EACF,MAAM,EACN,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE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iCzB;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAAgB;IAC1D,IAAI,CAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAA;KACtB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { Writable } from 'node:stream'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport stripAnsi from 'strip-ansi'\nimport { Plugin } from '../plugin'\nimport HttpStream from './http_stream'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: Plugin = async ({\n on,\n logger,\n configuration,\n environment,\n}) => {\n if (!configuration.formats.publish) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } =\n configuration.formats.publish\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n environment.stderr.write(\n sanitisePublishOutput(responseBody, environment.stderr) + '\\n'\n )\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n stream.on('error', (error: Error) => logger.error(error.message))\n on('message', (value) => stream.write(JSON.stringify(value) + '\\n'))\n return () =>\n new Promise<void>((resolve) => {\n stream.on('finish', () => resolve())\n stream.end()\n })\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripAnsi(raw)\n }\n return raw\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { EventEmitter } from 'events';
2
+ import { EventEmitter } from 'node:events';
3
3
  import * as messages from '@cucumber/messages';
4
4
  import { IdGenerator } from '@cucumber/messages';
5
5
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
@@ -1 +1 @@
1
- {"version":3,"file":"assemble_test_cases.js","sourceRoot":"","sources":["../../src/runtime/assemble_test_cases.ts"],"names":[],"mappings":";;;AAKA,oDAAgD;AAWzC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,GACQ;IAC1B,MAAM,MAAM,GAAwB,EAAE,CAAA;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;QAC/B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAA;QAC1B,MAAM,eAAe,GAAwB,mBAAmB,CAAC;YAC/D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,mBAAmB,GAAwB,SAAS,CAAC;YACzD,MAAM;YACN,kBAAkB;YAClB,KAAK;SACN,CAAC,CAAA;QACF,MAAM,cAAc,GAAwB,kBAAkB,CAAC;YAC7D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,QAAQ,GAAsB;YAClC,QAAQ;YACR,EAAE,EAAE,UAAU;YACd,SAAS,EAAE;gBACT,GAAG,eAAe;gBAClB,GAAG,mBAAmB;gBACtB,GAAG,cAAc;aAClB;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;KAC5B;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAtCD,8CAsCC;AAED,SAAS,kBAAkB,CAAC,EAC1B,kBAAkB,EAClB,MAAM,EACN,KAAK,GAKN;IACC,OAAO,kBAAkB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UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;gBAC/D,OAAO;oBACL,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;wBACrC,OAAO;4BACL,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;4BAClC,iBAAiB,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI;yBAC1C,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAY;IACpC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,IAAA,6BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC,CAAC,SAAS;KACd,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { doesHaveValue } from '../value_checker'\n\nexport declare type IAssembledTestCases = Record<string, messages.TestCase>\n\nexport interface IAssembleTestCasesOptions {\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n pickles: messages.Pickle[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport async function assembleTestCases({\n eventBroadcaster,\n newId,\n pickles,\n supportCodeLibrary,\n}: IAssembleTestCasesOptions): Promise<IAssembledTestCases> {\n const result: IAssembledTestCases = {}\n for (const pickle of pickles) {\n const { id: pickleId } = pickle\n const testCaseId = newId()\n const fromBeforeHooks: messages.TestStep[] = makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const fromStepDefinitions: messages.TestStep[] = makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n })\n const fromAfterHooks: messages.TestStep[] = makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const testCase: messages.TestCase = {\n pickleId,\n id: testCaseId,\n testSteps: [\n ...fromBeforeHooks,\n ...fromStepDefinitions,\n ...fromAfterHooks,\n ],\n }\n eventBroadcaster.emit('envelope', { testCase })\n result[pickleId] = testCase\n }\n return result\n}\n\nfunction makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.afterTestCaseHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.beforeTestCaseHookDefinitions\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n}: {\n pickle: messages.Pickle\n supportCodeLibrary: ISupportCodeLibrary\n newId: () => string\n}): messages.TestStep[] {\n return pickle.steps.map((pickleStep) => {\n const stepDefinitions = supportCodeLibrary.stepDefinitions.filter(\n (stepDefinition) => stepDefinition.matchesStepName(pickleStep.text)\n )\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n stepDefinitionIds: stepDefinitions.map(\n (stepDefinition) => stepDefinition.id\n ),\n stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {\n const result = stepDefinition.expression.match(pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n })\n}\n\nfunction mapArgumentGroup(group: Group): messages.Group {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => mapArgumentGroup(child))\n : undefined,\n }\n}\n"]}
1
+ {"version":3,"file":"assemble_test_cases.js","sourceRoot":"","sources":["../../src/runtime/assemble_test_cases.ts"],"names":[],"mappings":";;;AAKA,oDAAgD;AAWzC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,GACQ;IAC1B,MAAM,MAAM,GAAwB,EAAE,CAAA;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;QAC/B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAA;QAC1B,MAAM,eAAe,GAAwB,mBAAmB,CAAC;YAC/D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,mBAAmB,GAAwB,SAAS,CAAC;YACzD,MAAM;YACN,kBAAkB;YAClB,KAAK;SACN,CAAC,CAAA;QACF,MAAM,cAAc,GAAwB,kBAAkB,CAAC;YAC7D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,QAAQ,GAAsB;YAClC,QAAQ;YACR,EAAE,EAAE,UAAU;YACd,SAAS,EAAE;gBACT,GAAG,eAAe;gBAClB,GAAG,mBAAmB;gBACtB,GAAG,cAAc;aAClB;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;KAC5B;IACD,OAAO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Ac,CAAC,EAAE,CACtC;YACD,uBAAuB,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;gBAC9D,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;gBAC/D,OAAO;oBACL,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;wBACrC,OAAO;4BACL,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;4BAClC,iBAAiB,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI;yBAC1C,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAY;IACpC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,IAAA,6BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxD,CAAC,CAAC,SAAS;KACd,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { doesHaveValue } from '../value_checker'\n\nexport declare type IAssembledTestCases = Record<string, messages.TestCase>\n\nexport interface IAssembleTestCasesOptions {\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n pickles: messages.Pickle[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport async function assembleTestCases({\n eventBroadcaster,\n newId,\n pickles,\n supportCodeLibrary,\n}: IAssembleTestCasesOptions): Promise<IAssembledTestCases> {\n const result: IAssembledTestCases = {}\n for (const pickle of pickles) {\n const { id: pickleId } = pickle\n const testCaseId = newId()\n const fromBeforeHooks: messages.TestStep[] = makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const fromStepDefinitions: messages.TestStep[] = makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n })\n const fromAfterHooks: messages.TestStep[] = makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const testCase: messages.TestCase = {\n pickleId,\n id: testCaseId,\n testSteps: [\n ...fromBeforeHooks,\n ...fromStepDefinitions,\n ...fromAfterHooks,\n ],\n }\n eventBroadcaster.emit('envelope', { testCase })\n result[pickleId] = testCase\n }\n return result\n}\n\nfunction makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.afterTestCaseHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.beforeTestCaseHookDefinitions\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n}: {\n pickle: messages.Pickle\n supportCodeLibrary: ISupportCodeLibrary\n newId: () => string\n}): messages.TestStep[] {\n return pickle.steps.map((pickleStep) => {\n const stepDefinitions = supportCodeLibrary.stepDefinitions.filter(\n (stepDefinition) => stepDefinition.matchesStepName(pickleStep.text)\n )\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n stepDefinitionIds: stepDefinitions.map(\n (stepDefinition) => stepDefinition.id\n ),\n stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {\n const result = stepDefinition.expression.match(pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n })\n}\n\nfunction mapArgumentGroup(group: Group): messages.Group {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => mapArgumentGroup(child))\n : undefined,\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { Readable } from 'stream';
3
+ import { Readable } from 'node:stream';
4
4
  import * as messages from '@cucumber/messages';
5
5
  export interface IAttachmentMedia {
6
6
  encoding: messages.AttachmentContentEncoding;
@@ -30,6 +30,7 @@ const is_stream_1 = __importDefault(require("is-stream"));
30
30
  const messages = __importStar(require("@cucumber/messages"));
31
31
  const value_checker_1 = require("../../value_checker");
32
32
  class AttachmentManager {
33
+ onAttachment;
33
34
  constructor(onAttachment) {
34
35
  this.onAttachment = onAttachment;
35
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAgC;AAEhC,6DAA8C;AAC9C,uDAAqE;AA0CrE,MAAqB,iBAAiB;IAGpC,YAAY,YAA6B;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CACJ,IAAgC,EAChC,kBAAsD,EACtD,QAAqB;QAErB,MAAM,OAAO,GAAG,gBAAgB,C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AC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC;CACF;AAhHD,oCAgHC;AAED,SAAS,gBAAgB,CACvB,kBAAsD;IAEtD,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,EAAE,CAAA;KACV;IACD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;QAC1C,OAAO;YACL,SAAS,EAAE,kBAAkB;SAC9B,CAAA;KACF;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import isStream from 'is-stream'\nimport { Readable } from 'stream'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\nexport interface IAttachmentMedia {\n encoding: messages.AttachmentContentEncoding\n contentType: string\n}\n\nexport interface IAttachment {\n data: string\n media: IAttachmentMedia\n fileName?: string\n}\n\nexport type IAttachFunction = (attachment: IAttachment) => void\n\nexport interface ICreateAttachmentOptions {\n mediaType: string\n fileName?: string\n}\nexport type ICreateStringAttachment = (\n data: string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n) => void\nexport type ICreateBufferAttachment = (\n data: Buffer,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => void\nexport type ICreateStreamAttachment = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => Promise<void>\nexport type ICreateStreamAttachmentWithCallback = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions,\n callback: () => void\n) => void\nexport type ICreateAttachment = ICreateStringAttachment &\n ICreateBufferAttachment &\n ICreateStreamAttachment &\n ICreateStreamAttachmentWithCallback\nexport type ICreateLog = (text: string) => void\n\nexport default class AttachmentManager {\n private readonly onAttachment: IAttachFunction\n\n constructor(onAttachment: IAttachFunction) {\n this.onAttachment = onAttachment\n }\n\n log(text: string): void | Promise<void> {\n return this.create(text, 'text/x.cucumber.log+plain')\n }\n\n create(\n data: Buffer | Readable | string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions,\n callback?: () => void\n ): void | Promise<void> {\n const options = normaliseOptions(mediaTypeOrOptions)\n if (Buffer.isBuffer(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Buffer attachments must specify a media type')\n }\n this.createBufferAttachment(data, options.mediaType, options.fileName)\n } else if (isStream.readable(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Stream attachments must specify a media type')\n }\n return this.createStreamAttachment(\n data,\n options.mediaType,\n options.fileName,\n callback\n )\n } else if (typeof data === 'string') {\n if (doesNotHaveValue(options.mediaType)) {\n options.mediaType = 'text/plain'\n }\n if (options.mediaType.startsWith('base64:')) {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: options.mediaType.replace('base64:', ''),\n },\n options.fileName\n )\n } else {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.IDENTITY,\n contentType: options.mediaType,\n },\n options.fileName\n )\n }\n } else {\n throw Error(\n 'Invalid attachment data: must be a buffer, readable stream, or string'\n )\n }\n }\n\n createBufferAttachment(\n data: Buffer,\n mediaType: string,\n fileName?: string\n ): void {\n this.createStringAttachment(\n data.toString('base64'),\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType,\n },\n fileName\n )\n }\n\n createStreamAttachment(\n data: Readable,\n mediaType: string,\n fileName?: string,\n callback?: () => void\n ): void | Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n const buffers: Uint8Array[] = []\n data.on('data', (chunk) => {\n buffers.push(chunk)\n })\n data.on('end', () => {\n this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName)\n resolve()\n })\n data.on('error', reject)\n })\n if (doesHaveValue(callback)) {\n promise.then(callback, callback)\n } else {\n return promise\n }\n }\n\n createStringAttachment(\n data: string,\n media: IAttachmentMedia,\n fileName?: string\n ): void {\n this.onAttachment({\n data,\n media,\n ...(fileName ? { fileName } : {}),\n })\n }\n}\n\nfunction normaliseOptions(\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n): Partial<ICreateAttachmentOptions> {\n if (!mediaTypeOrOptions) {\n return {}\n }\n if (typeof mediaTypeOrOptions === 'string') {\n return {\n mediaType: mediaTypeOrOptions,\n }\n }\n return mediaTypeOrOptions\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0DAAgC;AAChC,6DAA8C;AAC9C,uDAAqE;AA0CrE,MAAqB,iBAAiB;IACnB,YAAY,CAAiB;IAE9C,YAAY,YAA6B;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CACJ,IAAgC,EAChC,kBAAsD,EACtD,QAAqB;QAErB,MAAM,OAAO,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;QACpD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,IAAI,IAAA,gCAAgB,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBACvC,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;aAC5D;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;SACvE;aAAM,IAAI,mBAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAClC,IAAI,IAAA,gCAAgB,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBACvC,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;aAC5D;YACD,OAAO,IAAI,CAAC,sBAAsB,CAChC,IAAI,EACJ,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,QAAQ,EAChB,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AO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBAClB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;gBACxE,OAAO,EAAE,CAAA;YACX,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;QACF,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;SACjC;aAAM;YACL,OAAO,OAAO,CAAA;SACf;IACH,CAAC;IAED,sBAAsB,CACpB,IAAY,EACZ,KAAuB,EACvB,QAAiB;QAEjB,IAAI,CAAC,YAAY,CAAC;YAChB,IAAI;YACJ,KAAK;YACL,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC;CACF;AAhHD,oCAgHC;AAED,SAAS,gBAAgB,CACvB,kBAAsD;IAEtD,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,EAAE,CAAA;KACV;IACD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;QAC1C,OAAO;YACL,SAAS,EAAE,kBAAkB;SAC9B,CAAA;KACF;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import { Readable } from 'node:stream'\nimport isStream from 'is-stream'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\nexport interface IAttachmentMedia {\n encoding: messages.AttachmentContentEncoding\n contentType: string\n}\n\nexport interface IAttachment {\n data: string\n media: IAttachmentMedia\n fileName?: string\n}\n\nexport type IAttachFunction = (attachment: IAttachment) => void\n\nexport interface ICreateAttachmentOptions {\n mediaType: string\n fileName?: string\n}\nexport type ICreateStringAttachment = (\n data: string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n) => void\nexport type ICreateBufferAttachment = (\n data: Buffer,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => void\nexport type ICreateStreamAttachment = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => Promise<void>\nexport type ICreateStreamAttachmentWithCallback = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions,\n callback: () => void\n) => void\nexport type ICreateAttachment = ICreateStringAttachment &\n ICreateBufferAttachment &\n ICreateStreamAttachment &\n ICreateStreamAttachmentWithCallback\nexport type ICreateLog = (text: string) => void\n\nexport default class AttachmentManager {\n private readonly onAttachment: IAttachFunction\n\n constructor(onAttachment: IAttachFunction) {\n this.onAttachment = onAttachment\n }\n\n log(text: string): void | Promise<void> {\n return this.create(text, 'text/x.cucumber.log+plain')\n }\n\n create(\n data: Buffer | Readable | string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions,\n callback?: () => void\n ): void | Promise<void> {\n const options = normaliseOptions(mediaTypeOrOptions)\n if (Buffer.isBuffer(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Buffer attachments must specify a media type')\n }\n this.createBufferAttachment(data, options.mediaType, options.fileName)\n } else if (isStream.readable(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Stream attachments must specify a media type')\n }\n return this.createStreamAttachment(\n data,\n options.mediaType,\n options.fileName,\n callback\n )\n } else if (typeof data === 'string') {\n if (doesNotHaveValue(options.mediaType)) {\n options.mediaType = 'text/plain'\n }\n if (options.mediaType.startsWith('base64:')) {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: options.mediaType.replace('base64:', ''),\n },\n options.fileName\n )\n } else {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.IDENTITY,\n contentType: options.mediaType,\n },\n options.fileName\n )\n }\n } else {\n throw Error(\n 'Invalid attachment data: must be a buffer, readable stream, or string'\n )\n }\n }\n\n createBufferAttachment(\n data: Buffer,\n mediaType: string,\n fileName?: string\n ): void {\n this.createStringAttachment(\n data.toString('base64'),\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType,\n },\n fileName\n )\n }\n\n createStreamAttachment(\n data: Readable,\n mediaType: string,\n fileName?: string,\n callback?: () => void\n ): void | Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n const buffers: Uint8Array[] = []\n data.on('data', (chunk) => {\n buffers.push(chunk)\n })\n data.on('end', () => {\n this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName)\n resolve()\n })\n data.on('error', reject)\n })\n if (doesHaveValue(callback)) {\n promise.then(callback, callback)\n } else {\n return promise\n }\n }\n\n createStringAttachment(\n data: string,\n media: IAttachmentMedia,\n fileName?: string\n ): void {\n this.onAttachment({\n data,\n media,\n ...(fileName ? { fileName } : {}),\n })\n }\n}\n\nfunction normaliseOptions(\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n): Partial<ICreateAttachmentOptions> {\n if (!mediaTypeOrOptions) {\n return {}\n }\n if (typeof mediaTypeOrOptions === 'string') {\n return {\n mediaType: mediaTypeOrOptions,\n }\n }\n return mediaTypeOrOptions\n}\n"]}
@@ -15,7 +15,7 @@ function formatError(error, filterStackTraces) {
15
15
  .map((f) => f.source)
16
16
  .join('\n');
17
17
  }
18
- catch (_a) {
18
+ catch {
19
19
  // if we weren't able to parse and filter, we'll settle for the original
20
20
  }
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"format_error.js","sourceRoot":"","sources":["../../src/runtime/format_error.ts"],"names":[],"mappings":";;;;;;AACA,yEAAkD;AAClD,4EAAiD;AACjD,8DAAwD;AAExD,SAAgB,WAAW,CACzB,KAAY,EACZ,iBAA0B;IAE1B,IAAI,aAAqB,CAAA;IACzB,IAAI,iBAAiB,EAAE;QACrB,IAAI;YACF,aAAa,GAAG,IAAA,qCAAgB,EAAC,4BAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,CAAA;SACd;QAAC,WAAM;YACN,wEAAwE;SACzE;KACF;IACD,MAAM,OAAO,GAAG,IAAA,kCAAM,EAAC,KAAK,EAAE;QAC5B,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAC5B,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK;SAC/C;KACF,CAAC,CAAA;IACF,OAAO;QACL,OAAO;QACP,SAAS,EAAE;YACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;YAC3B,OAAO,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO;SAC3D;KACF,CAAA;AACH,CAAC;AA3BD,kCA2BC","sourcesContent":["import { TestStepResult } from '@cucumber/messages'\nimport { format } from 'assertion-error-formatter'\nimport errorStackParser from 'error-stack-parser'\nimport { filterStackTrace } from '../filter_stack_trace'\n\nexport function formatError(\n error: Error,\n filterStackTraces: boolean\n): Pick<TestStepResult, 'message' | 'exception'> {\n let filteredStack: string\n if (filterStackTraces) {\n try {\n filteredStack = filterStackTrace(errorStackParser.parse(error))\n .map((f) => f.source)\n .join('\\n')\n } catch {\n // if we weren't able to parse and filter, we'll settle for the original\n }\n }\n const message = format(error, {\n colorFns: {\n errorStack: (stack: string) =>\n filteredStack ? `\\n${filteredStack}` : stack,\n },\n })\n return {\n message,\n exception: {\n type: error.name || 'Error',\n message: typeof error === 'string' ? error : error.message,\n },\n }\n}\n"]}
1
+ {"version":3,"file":"format_error.js","sourceRoot":"","sources":["../../src/runtime/format_error.ts"],"names":[],"mappings":";;;;;;AACA,yEAAkD;AAClD,4EAAiD;AACjD,8DAAwD;AAExD,SAAgB,WAAW,CACzB,KAAY,EACZ,iBAA0B;IAE1B,IAAI,aAAqB,CAAA;IACzB,IAAI,iBAAiB,EAAE;QACrB,IAAI;YACF,aAAa,GAAG,IAAA,qCAAgB,EAAC,4BAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,CAAA;SACd;QAAC,MAAM;YACN,wEAAwE;SACzE;KACF;IACD,MAAM,OAAO,GAAG,IAAA,kCAAM,EAAC,KAAK,EAAE;QAC5B,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAC5B,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK;SAC/C;KACF,CAAC,CAAA;IACF,OAAO;QACL,OAAO;QACP,SAAS,EAAE;YACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;YAC3B,OAAO,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO;SAC3D;KACF,CAAA;AACH,CAAC;AA3BD,kCA2BC","sourcesContent":["import { TestStepResult } from '@cucumber/messages'\nimport { format } from 'assertion-error-formatter'\nimport errorStackParser from 'error-stack-parser'\nimport { filterStackTrace } from '../filter_stack_trace'\n\nexport function formatError(\n error: Error,\n filterStackTraces: boolean\n): Pick<TestStepResult, 'message' | 'exception'> {\n let filteredStack: string\n if (filterStackTraces) {\n try {\n filteredStack = filterStackTrace(errorStackParser.parse(error))\n .map((f) => f.source)\n .join('\\n')\n } catch {\n // if we weren't able to parse and filter, we'll settle for the original\n }\n }\n const message = format(error, {\n colorFns: {\n errorStack: (stack: string) =>\n filteredStack ? `\\n${filteredStack}` : stack,\n },\n })\n return {\n message,\n exception: {\n type: error.name || 'Error',\n message: typeof error === 'string' ? error : error.message,\n },\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import StepDefinition from '../models/step_definition';
2
1
  import * as messages from '@cucumber/messages';
2
+ import StepDefinition from '../models/step_definition';
3
3
  import { IRuntimeOptions } from '.';
4
4
  export declare function getAmbiguousStepException(stepDefinitions: StepDefinition[]): string;
5
5
  export declare function retriesForPickle(pickle: messages.Pickle, options: IRuntimeOptions): number;
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.shouldCauseFailure = exports.retriesForPickle = exports.getAmbiguousStepException = void 0;
30
- const location_helpers_1 = require("../formatter/helpers/location_helpers");
31
30
  const cli_table3_1 = __importDefault(require("cli-table3"));
32
31
  const indent_string_1 = __importDefault(require("indent-string"));
33
- const pickle_filter_1 = require("../pickle_filter");
34
32
  const messages = __importStar(require("@cucumber/messages"));
33
+ const location_helpers_1 = require("../formatter/helpers/location_helpers");
34
+ const pickle_filter_1 = require("../pickle_filter");
35
35
  function getAmbiguousStepException(stepDefinitions) {
36
36
  const table = new cli_table3_1.default({
37
37
  chars: {
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsE;AACtE,4DAA8B;AAC9B,kEAAwC;AACxC,oDAAkD;AAElD,6DAA8C;AAG9C,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EA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BC;AAED,SAAgB,kBAAkB,CAChC,MAAqC,EACrC,OAAwB;IAExB,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,OAAO,KAAK,CAAA;KACb;IACD,MAAM,eAAe,GAAoC;QACvD,QAAQ,CAAC,oBAAoB,CAAC,SAAS;QACvC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;QACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;KACxC,CAAA;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC5D;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","sourcesContent":["import { formatLocation } from '../formatter/helpers/location_helpers'\nimport Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport * as messages from '@cucumber/messages'\nimport { IRuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: IRuntimeOptions\n): number {\n if (!options.retry) {\n return 0\n }\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (!retryTagFilter) {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: IRuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8B;AAC9B,kEAAwC;AACxC,6DAA8C;AAC9C,4EAAsE;AACtE,oDAAkD;AAIlD,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,WAAW,EAAE,EAAE;SAChB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,CAAC;SACnB;KACF,CAAC,CAAA;IACF,KAAK,CAAC,IAAI,CACR,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;QACxC,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AO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","sourcesContent":["import Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport { formatLocation } from '../formatter/helpers/location_helpers'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport { IRuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: IRuntimeOptions\n): number {\n if (!options.retry) {\n return 0\n }\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (!retryTagFilter) {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: IRuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import { EventEmitter } from 'node:events';
2
3
  import * as messages from '@cucumber/messages';
3
4
  import { IdGenerator } from '@cucumber/messages';
4
- import { EventEmitter } from 'events';
5
5
  import { EventDataCollector } from '../formatter/helpers';
6
6
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
7
7
  export interface IRuntime {
@@ -9,6 +9,15 @@ const run_test_run_hooks_1 = require("./run_test_run_hooks");
9
9
  const stopwatch_1 = require("./stopwatch");
10
10
  const test_case_runner_1 = __importDefault(require("./test_case_runner"));
11
11
  class Runtime {
12
+ eventBroadcaster;
13
+ eventDataCollector;
14
+ stopwatch;
15
+ newId;
16
+ options;
17
+ pickleIds;
18
+ supportCodeLibrary;
19
+ success;
20
+ runTestRunHooks;
12
21
  constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
13
22
  this.eventBroadcaster = eventBroadcaster;
14
23
  this.eventDataCollector = eventDataCollector;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAKA,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAgD;AAChD,0EAA+C;AAyB/C,MAAqB,OAAO;IAW1B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GACC;QACnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAA,kBAAM,GAAE,CAAA;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAA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AAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAjGD,0BAiGC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { IStopwatch, create } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime implements IRuntime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) => `${name} hook errored, process exiting: ${location}`\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.options.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (shouldCauseFailure(status, this.options)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n return this.success\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAKA,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;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AE,EAAE,CACvC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC5C;YACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAA;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC/D;QACD,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EACtE,aAAa,CACd,CAAA;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACrB,MAAM,eAAe,GAAsB;YACzC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;gBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAA;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAjGD,0BAiGC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { IStopwatch, create } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime implements IRuntime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) => `${name} hook errored, process exiting: ${location}`\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.options.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (shouldCauseFailure(status, this.options)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n return this.success\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { ChildProcess } from 'child_process';
3
+ import { ChildProcess } from 'node:child_process';
4
+ import { EventEmitter } from 'node:events';
4
5
  import * as messages from '@cucumber/messages';
5
- import { EventEmitter } from 'events';
6
+ import { IdGenerator } from '@cucumber/messages';
6
7
  import { EventDataCollector } from '../../formatter/helpers';
7
8
  import { IRuntime, IRuntimeOptions } from '..';
8
9
  import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
9
- import { ICoordinatorReport } from './command_types';
10
- import { IdGenerator } from '@cucumber/messages';
11
10
  import { ILogger } from '../../logger';
11
+ import { ICoordinatorReport } from './command_types';
12
12
  export interface INewCoordinatorOptions {
13
13
  cwd: string;
14
14
  logger: ILogger;
@@ -26,15 +26,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const child_process_1 = require("child_process");
30
- const path_1 = __importDefault(require("path"));
31
- const helpers_1 = require("../helpers");
29
+ const node_child_process_1 = require("node:child_process");
30
+ const node_path_1 = __importDefault(require("node:path"));
32
31
  const messages = __importStar(require("@cucumber/messages"));
32
+ const helpers_1 = require("../helpers");
33
33
  const value_checker_1 = require("../../value_checker");
34
34
  const stopwatch_1 = require("../stopwatch");
35
35
  const assemble_test_cases_1 = require("../assemble_test_cases");
36
- const runWorkerPath = path_1.default.resolve(__dirname, 'run_worker.js');
36
+ const runWorkerPath = node_path_1.default.resolve(__dirname, 'run_worker.js');
37
37
  class Coordinator {
38
+ cwd;
39
+ eventBroadcaster;
40
+ eventDataCollector;
41
+ stopwatch;
42
+ onFinish;
43
+ options;
44
+ newId;
45
+ pickleIds;
46
+ assembledTestCases;
47
+ inProgressPickles;
48
+ workers;
49
+ supportCodeLibrary;
50
+ requireModules;
51
+ requirePaths;
52
+ importPaths;
53
+ numberOfWorkers;
54
+ logger;
55
+ success;
56
+ idleInterventions;
38
57
  constructor({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, options, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, numberOfWorkers, }) {
39
58
  this.cwd = cwd;
40
59
  this.logger = logger;
@@ -85,7 +104,7 @@ class Coordinator {
85
104
  }
86
105
  }
87
106
  startWorker(id, total) {
88
- const workerProcess = (0, child_process_1.fork)(runWorkerPath, [], {
107
+ const workerProcess = (0, node_child_process_1.fork)(runWorkerPath, [], {
89
108
  cwd: this.cwd,
90
109
  env: {
91
110
  ...process.env,
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/parallel/coordinator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkD;AAClD,gDAAuB;AACvB,wCAAiE;AACjE,6DAA8C;AAM9C,uDAAmD;AACnD,4CAAiD;AACjD,gEAA+E;AAI/E,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AAmC9D,MAAqB,WAAW;IAqB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AC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5E,MAAM,UAAU,GAAmB;YACjC,GAAG,EAAE;gBACH,OAAO;gBACP,IAAI;gBACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAClC,MAAM;gBACN,QAAQ;gBACR,eAAe;aAChB;SACF,CAAA;QACD,MAAM,CAAC,KAAK,8BAAsB,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjC,CAAC;CACF;AApQD,8BAoQC","sourcesContent":["import { ChildProcess, fork } from 'child_process'\nimport path from 'path'\nimport { retriesForPickle, shouldCauseFailure } from '../helpers'\nimport * as messages from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../../formatter/helpers'\nimport { IRuntime, IRuntimeOptions } from '..'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { ICoordinatorReport, IWorkerCommand } from './command_types'\nimport { doesHaveValue } from '../../value_checker'\nimport { IStopwatch, create } from '../stopwatch'\nimport { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ILogger } from '../../logger'\n\nconst runWorkerPath = path.resolve(__dirname, 'run_worker.js')\n\nexport interface INewCoordinatorOptions {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n options: IRuntimeOptions\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n numberOfWorkers: number\n}\n\nconst enum WorkerState {\n 'idle',\n 'closed',\n 'running',\n 'new',\n}\n\ninterface IWorker {\n state: WorkerState\n process: ChildProcess\n id: string\n}\n\ninterface IPicklePlacement {\n index: number\n pickle: messages.Pickle\n}\n\nexport default class Coordinator implements IRuntime {\n private readonly cwd: string\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private onFinish: (success: boolean) => void\n private readonly options: IRuntimeOptions\n private readonly newId: IdGenerator.NewId\n private readonly pickleIds: string[]\n private assembledTestCases: IAssembledTestCases\n private inProgressPickles: Record<string, messages.Pickle>\n private workers: Record<string, IWorker>\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private readonly requireModules: string[]\n private readonly requirePaths: string[]\n private readonly importPaths: string[]\n private readonly numberOfWorkers: number\n private readonly logger: ILogger\n private success: boolean\n private idleInterventions: number\n\n constructor({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n requireModules,\n requirePaths,\n importPaths,\n numberOfWorkers,\n }: INewCoordinatorOptions) {\n this.cwd = cwd\n this.logger = logger\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.options = options\n this.newId = newId\n this.supportCodeLibrary = supportCodeLibrary\n this.requireModules = requireModules\n this.requirePaths = requirePaths\n this.importPaths = importPaths\n this.pickleIds = Array.from(pickleIds)\n this.numberOfWorkers = numberOfWorkers\n this.success = true\n this.workers = {}\n this.inProgressPickles = {}\n this.idleInterventions = 0\n }\n\n parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void {\n if (message.ready) {\n worker.state = WorkerState.idle\n this.awakenWorkers(worker)\n } else if (doesHaveValue(message.jsonEnvelope)) {\n const envelope = messages.parseEnvelope(message.jsonEnvelope)\n this.eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.testCaseFinished)) {\n delete this.inProgressPickles[worker.id]\n this.parseTestCaseResult(envelope.testCaseFinished)\n }\n } else {\n throw new Error(\n `Unexpected message from worker: ${JSON.stringify(message)}`\n )\n }\n }\n\n awakenWorkers(triggeringWorker: IWorker): void {\n Object.values(this.workers).forEach((worker) => {\n if (worker.state === WorkerState.idle) {\n this.giveWork(worker)\n }\n return worker.state !== WorkerState.idle\n })\n\n if (\n Object.keys(this.inProgressPickles).length == 0 &&\n this.pickleIds.length > 0\n ) {\n this.giveWork(triggeringWorker, true)\n this.idleInterventions++\n }\n }\n\n startWorker(id: string, total: number): void {\n const workerProcess = fork(runWorkerPath, [], {\n cwd: this.cwd,\n env: {\n ...process.env,\n CUCUMBER_PARALLEL: 'true',\n CUCUMBER_TOTAL_WORKERS: total.toString(),\n CUCUMBER_WORKER_ID: id,\n },\n stdio: ['inherit', 'inherit', 'inherit', 'ipc'],\n })\n const worker = { state: WorkerState.new, process: workerProcess, id }\n this.workers[id] = worker\n worker.process.on('message', (message: ICoordinatorReport) => {\n this.parseWorkerMessage(worker, message)\n })\n worker.process.on('close', (exitCode) => {\n worker.state = WorkerState.closed\n this.onWorkerProcessClose(exitCode)\n })\n const initializeCommand: IWorkerCommand = {\n initialize: {\n filterStacktraces: this.options.filterStacktraces,\n requireModules: this.requireModules,\n requirePaths: this.requirePaths,\n importPaths: this.importPaths,\n supportCodeIds: {\n stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map(\n (s) => s.id\n ),\n beforeTestCaseHookDefinitionIds:\n this.supportCodeLibrary.beforeTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n afterTestCaseHookDefinitionIds:\n this.supportCodeLibrary.afterTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n },\n options: this.options,\n },\n }\n worker.process.send(initializeCommand)\n }\n\n onWorkerProcessClose(exitCode: number): void {\n const success = exitCode === 0\n if (!success) {\n this.success = false\n }\n\n if (\n Object.values(this.workers).every((x) => x.state === WorkerState.closed)\n ) {\n const envelope: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success,\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.onFinish(this.success)\n }\n }\n\n parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (\n !testCaseFinished.willBeRetried &&\n shouldCauseFailure(worstTestStepResult.status, this.options)\n ) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const envelope: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.stopwatch.start()\n this.assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n return await new Promise<boolean>((resolve) => {\n for (let i = 0; i < this.numberOfWorkers; i++) {\n this.startWorker(i.toString(), this.numberOfWorkers)\n }\n this.onFinish = (status) => {\n if (this.idleInterventions > 0) {\n this.logger.warn(\n `WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`\n )\n }\n\n resolve(status)\n }\n })\n }\n\n nextPicklePlacement(): IPicklePlacement {\n for (let index = 0; index < this.pickleIds.length; index++) {\n const placement = this.placementAt(index)\n if (\n this.supportCodeLibrary.parallelCanAssign(\n placement.pickle,\n Object.values(this.inProgressPickles)\n )\n ) {\n return placement\n }\n }\n\n return null\n }\n\n placementAt(index: number): IPicklePlacement {\n return {\n index,\n pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),\n }\n }\n\n giveWork(worker: IWorker, force: boolean = false): void {\n if (this.pickleIds.length < 1) {\n const finalizeCommand: IWorkerCommand = { finalize: true }\n worker.state = WorkerState.running\n worker.process.send(finalizeCommand)\n return\n }\n\n const picklePlacement = force\n ? this.placementAt(0)\n : this.nextPicklePlacement()\n\n if (picklePlacement === null) {\n return\n }\n\n const { index: nextPickleIndex, pickle } = picklePlacement\n\n this.pickleIds.splice(nextPickleIndex, 1)\n this.inProgressPickles[worker.id] = pickle\n const testCase = this.assembledTestCases[pickle.id]\n const gherkinDocument = this.eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const runCommand: IWorkerCommand = {\n run: {\n retries,\n skip,\n elapsed: this.stopwatch.duration(),\n pickle,\n testCase,\n gherkinDocument,\n },\n }\n worker.state = WorkerState.running\n worker.process.send(runCommand)\n }\n}\n"]}
1
+ {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/parallel/coordinator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAuD;AACvD,0DAA4B;AAE5B,6DAA8C;AAE9C,wCAAiE;AAIjE,uDAAmD;AACnD,4CAAiD;AACjD,gEAA+E;AAI/E,MAAM,aAAa,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AAmC9D,MAAqB,WAAW;IACb,GAAG,CAAQ;IACX,gBAAgB,CAAc;IAC9B,kBAAkB,CAAoB;IACtC,SAAS,CAAY;IAC9B,QAAQ,CAA4B;IAC3B,OAAO,CAAiB;IACxB,KAAK,CAAmB;IACxB,SAAS,CAAU;IAC5B,kBAAkB,CAAqB;IACvC,iBAAiB,CAAiC;IAClD,OAAO,CAAyB;IACvB,kBAAkB,CAAqB;IACvC,cAAc,CAAU;IACxB,YAAY,CAAU;IACtB,WAAW,CAAU;IACrB,eAAe,CAAQ;IACvB,MAAM,CAAS;IACxB,OAAO,CAAS;IAChB,iBAAiB,CAAQ;IAEjC,YAAY,EACV,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,GACQ;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAA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AE;gBACH,OAAO;gBACP,IAAI;gBACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAClC,MAAM;gBACN,QAAQ;gBACR,eAAe;aAChB;SACF,CAAA;QACD,MAAM,CAAC,KAAK,8BAAsB,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjC,CAAC;CACF;AApQD,8BAoQC","sourcesContent":["import { ChildProcess, fork } from 'node:child_process'\nimport path from 'node:path'\nimport { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { retriesForPickle, shouldCauseFailure } from '../helpers'\nimport { EventDataCollector } from '../../formatter/helpers'\nimport { IRuntime, IRuntimeOptions } from '..'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { IStopwatch, create } from '../stopwatch'\nimport { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'\nimport { ILogger } from '../../logger'\nimport { ICoordinatorReport, IWorkerCommand } from './command_types'\n\nconst runWorkerPath = path.resolve(__dirname, 'run_worker.js')\n\nexport interface INewCoordinatorOptions {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n options: IRuntimeOptions\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n numberOfWorkers: number\n}\n\nconst enum WorkerState {\n 'idle',\n 'closed',\n 'running',\n 'new',\n}\n\ninterface IWorker {\n state: WorkerState\n process: ChildProcess\n id: string\n}\n\ninterface IPicklePlacement {\n index: number\n pickle: messages.Pickle\n}\n\nexport default class Coordinator implements IRuntime {\n private readonly cwd: string\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private onFinish: (success: boolean) => void\n private readonly options: IRuntimeOptions\n private readonly newId: IdGenerator.NewId\n private readonly pickleIds: string[]\n private assembledTestCases: IAssembledTestCases\n private inProgressPickles: Record<string, messages.Pickle>\n private workers: Record<string, IWorker>\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private readonly requireModules: string[]\n private readonly requirePaths: string[]\n private readonly importPaths: string[]\n private readonly numberOfWorkers: number\n private readonly logger: ILogger\n private success: boolean\n private idleInterventions: number\n\n constructor({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n requireModules,\n requirePaths,\n importPaths,\n numberOfWorkers,\n }: INewCoordinatorOptions) {\n this.cwd = cwd\n this.logger = logger\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.options = options\n this.newId = newId\n this.supportCodeLibrary = supportCodeLibrary\n this.requireModules = requireModules\n this.requirePaths = requirePaths\n this.importPaths = importPaths\n this.pickleIds = Array.from(pickleIds)\n this.numberOfWorkers = numberOfWorkers\n this.success = true\n this.workers = {}\n this.inProgressPickles = {}\n this.idleInterventions = 0\n }\n\n parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void {\n if (message.ready) {\n worker.state = WorkerState.idle\n this.awakenWorkers(worker)\n } else if (doesHaveValue(message.jsonEnvelope)) {\n const envelope = messages.parseEnvelope(message.jsonEnvelope)\n this.eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.testCaseFinished)) {\n delete this.inProgressPickles[worker.id]\n this.parseTestCaseResult(envelope.testCaseFinished)\n }\n } else {\n throw new Error(\n `Unexpected message from worker: ${JSON.stringify(message)}`\n )\n }\n }\n\n awakenWorkers(triggeringWorker: IWorker): void {\n Object.values(this.workers).forEach((worker) => {\n if (worker.state === WorkerState.idle) {\n this.giveWork(worker)\n }\n return worker.state !== WorkerState.idle\n })\n\n if (\n Object.keys(this.inProgressPickles).length == 0 &&\n this.pickleIds.length > 0\n ) {\n this.giveWork(triggeringWorker, true)\n this.idleInterventions++\n }\n }\n\n startWorker(id: string, total: number): void {\n const workerProcess = fork(runWorkerPath, [], {\n cwd: this.cwd,\n env: {\n ...process.env,\n CUCUMBER_PARALLEL: 'true',\n CUCUMBER_TOTAL_WORKERS: total.toString(),\n CUCUMBER_WORKER_ID: id,\n },\n stdio: ['inherit', 'inherit', 'inherit', 'ipc'],\n })\n const worker = { state: WorkerState.new, process: workerProcess, id }\n this.workers[id] = worker\n worker.process.on('message', (message: ICoordinatorReport) => {\n this.parseWorkerMessage(worker, message)\n })\n worker.process.on('close', (exitCode) => {\n worker.state = WorkerState.closed\n this.onWorkerProcessClose(exitCode)\n })\n const initializeCommand: IWorkerCommand = {\n initialize: {\n filterStacktraces: this.options.filterStacktraces,\n requireModules: this.requireModules,\n requirePaths: this.requirePaths,\n importPaths: this.importPaths,\n supportCodeIds: {\n stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map(\n (s) => s.id\n ),\n beforeTestCaseHookDefinitionIds:\n this.supportCodeLibrary.beforeTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n afterTestCaseHookDefinitionIds:\n this.supportCodeLibrary.afterTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n },\n options: this.options,\n },\n }\n worker.process.send(initializeCommand)\n }\n\n onWorkerProcessClose(exitCode: number): void {\n const success = exitCode === 0\n if (!success) {\n this.success = false\n }\n\n if (\n Object.values(this.workers).every((x) => x.state === WorkerState.closed)\n ) {\n const envelope: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success,\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.onFinish(this.success)\n }\n }\n\n parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (\n !testCaseFinished.willBeRetried &&\n shouldCauseFailure(worstTestStepResult.status, this.options)\n ) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const envelope: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.stopwatch.start()\n this.assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n return await new Promise<boolean>((resolve) => {\n for (let i = 0; i < this.numberOfWorkers; i++) {\n this.startWorker(i.toString(), this.numberOfWorkers)\n }\n this.onFinish = (status) => {\n if (this.idleInterventions > 0) {\n this.logger.warn(\n `WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`\n )\n }\n\n resolve(status)\n }\n })\n }\n\n nextPicklePlacement(): IPicklePlacement {\n for (let index = 0; index < this.pickleIds.length; index++) {\n const placement = this.placementAt(index)\n if (\n this.supportCodeLibrary.parallelCanAssign(\n placement.pickle,\n Object.values(this.inProgressPickles)\n )\n ) {\n return placement\n }\n }\n\n return null\n }\n\n placementAt(index: number): IPicklePlacement {\n return {\n index,\n pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),\n }\n }\n\n giveWork(worker: IWorker, force: boolean = false): void {\n if (this.pickleIds.length < 1) {\n const finalizeCommand: IWorkerCommand = { finalize: true }\n worker.state = WorkerState.running\n worker.process.send(finalizeCommand)\n return\n }\n\n const picklePlacement = force\n ? this.placementAt(0)\n : this.nextPicklePlacement()\n\n if (picklePlacement === null) {\n return\n }\n\n const { index: nextPickleIndex, pickle } = picklePlacement\n\n this.pickleIds.splice(nextPickleIndex, 1)\n this.inProgressPickles[worker.id] = pickle\n const testCase = this.assembledTestCases[pickle.id]\n const gherkinDocument = this.eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const runCommand: IWorkerCommand = {\n run: {\n retries,\n skip,\n elapsed: this.stopwatch.duration(),\n pickle,\n testCase,\n gherkinDocument,\n },\n }\n worker.state = WorkerState.running\n worker.process.send(runCommand)\n }\n}\n"]}