@dev-blinq/cucumber-js 1.0.10 → 1.0.12-stage

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 (257) hide show
  1. package/bin/cucumber-js +0 -0
  2. package/bin/cucumber.js +0 -0
  3. package/bin/download-install.js +126 -0
  4. package/lib/api/console_logger.d.ts +12 -12
  5. package/lib/api/console_logger.js +23 -23
  6. package/lib/api/convert_configuration.d.ts +4 -4
  7. package/lib/api/convert_configuration.js +65 -64
  8. package/lib/api/convert_configuration.js.map +1 -1
  9. package/lib/api/environment.d.ts +2 -2
  10. package/lib/api/environment.js +13 -13
  11. package/lib/api/formatters.d.ts +20 -20
  12. package/lib/api/formatters.js +60 -60
  13. package/lib/api/gherkin.d.ts +21 -21
  14. package/lib/api/gherkin.js +140 -99
  15. package/lib/api/gherkin.js.map +1 -1
  16. package/lib/api/index.d.ts +12 -12
  17. package/lib/api/index.js +27 -27
  18. package/lib/api/load_configuration.d.ts +9 -9
  19. package/lib/api/load_configuration.js +40 -40
  20. package/lib/api/load_sources.d.ts +9 -9
  21. package/lib/api/load_sources.js +52 -52
  22. package/lib/api/load_support.d.ts +10 -10
  23. package/lib/api/load_support.js +29 -29
  24. package/lib/api/paths.d.ts +8 -8
  25. package/lib/api/paths.js +101 -101
  26. package/lib/api/plugins.d.ts +4 -4
  27. package/lib/api/plugins.js +18 -18
  28. package/lib/api/run_cucumber.d.ts +11 -11
  29. package/lib/api/run_cucumber.js +114 -114
  30. package/lib/api/run_cucumber.js.map +1 -1
  31. package/lib/api/runtime.d.ts +21 -21
  32. package/lib/api/runtime.js +35 -35
  33. package/lib/api/support.d.ts +9 -9
  34. package/lib/api/support.js +25 -25
  35. package/lib/api/test_helpers.d.ts +3 -3
  36. package/lib/api/test_helpers.js +30 -30
  37. package/lib/api/types.d.ts +177 -175
  38. package/lib/api/types.js +2 -2
  39. package/lib/api/types.js.map +1 -1
  40. package/lib/cli/helpers.d.ts +39 -37
  41. package/lib/cli/helpers.js +223 -202
  42. package/lib/cli/helpers.js.map +1 -1
  43. package/lib/cli/i18n.d.ts +2 -2
  44. package/lib/cli/i18n.js +69 -69
  45. package/lib/cli/index.d.ts +21 -21
  46. package/lib/cli/index.js +63 -58
  47. package/lib/cli/index.js.map +1 -1
  48. package/lib/cli/install_validator.d.ts +1 -1
  49. package/lib/cli/install_validator.js +13 -13
  50. package/lib/cli/run.d.ts +1 -1
  51. package/lib/cli/run.js +43 -43
  52. package/lib/cli/validate_node_engine_version.d.ts +10 -10
  53. package/lib/cli/validate_node_engine_version.js +23 -23
  54. package/lib/configuration/argv_parser.d.ts +20 -20
  55. package/lib/configuration/argv_parser.js +102 -100
  56. package/lib/configuration/argv_parser.js.map +1 -1
  57. package/lib/configuration/check_schema.d.ts +2 -2
  58. package/lib/configuration/check_schema.js +59 -59
  59. package/lib/configuration/default_configuration.d.ts +2 -2
  60. package/lib/configuration/default_configuration.js +28 -26
  61. package/lib/configuration/default_configuration.js.map +1 -1
  62. package/lib/configuration/from_file.d.ts +3 -3
  63. package/lib/configuration/from_file.js +84 -84
  64. package/lib/configuration/helpers.d.ts +1 -1
  65. package/lib/configuration/helpers.js +10 -10
  66. package/lib/configuration/index.d.ts +7 -7
  67. package/lib/configuration/index.js +28 -28
  68. package/lib/configuration/locate_file.d.ts +1 -1
  69. package/lib/configuration/locate_file.js +20 -20
  70. package/lib/configuration/merge_configurations.d.ts +2 -2
  71. package/lib/configuration/merge_configurations.js +47 -47
  72. package/lib/configuration/option_splitter.d.ts +3 -3
  73. package/lib/configuration/option_splitter.js +22 -22
  74. package/lib/configuration/types.d.ts +30 -28
  75. package/lib/configuration/types.js +2 -2
  76. package/lib/configuration/types.js.map +1 -1
  77. package/lib/configuration/validate_configuration.d.ts +3 -3
  78. package/lib/configuration/validate_configuration.js +12 -12
  79. package/lib/filter_stack_trace.d.ts +3 -3
  80. package/lib/filter_stack_trace.js +37 -37
  81. package/lib/formatter/builder.d.ts +37 -37
  82. package/lib/formatter/builder.js +100 -100
  83. package/lib/formatter/bvt_analysis_formatter.d.ts +18 -0
  84. package/lib/formatter/bvt_analysis_formatter.js +193 -0
  85. package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
  86. package/lib/formatter/feature_data_format.d.ts +23 -14
  87. package/lib/formatter/feature_data_format.js +136 -80
  88. package/lib/formatter/feature_data_format.js.map +1 -1
  89. package/lib/formatter/fixtures/typescript.d.ts +2 -2
  90. package/lib/formatter/fixtures/typescript.js +5 -5
  91. package/lib/formatter/get_color_fns.d.ts +15 -15
  92. package/lib/formatter/get_color_fns.js +55 -55
  93. package/lib/formatter/helpers/duration_helpers.d.ts +2 -2
  94. package/lib/formatter/helpers/duration_helpers.js +8 -8
  95. package/lib/formatter/helpers/event_data_collector.d.ts +30 -30
  96. package/lib/formatter/helpers/event_data_collector.js +125 -125
  97. package/lib/formatter/helpers/formatters.d.ts +6 -6
  98. package/lib/formatter/helpers/formatters.js +44 -44
  99. package/lib/formatter/helpers/formatters.js.map +1 -1
  100. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -5
  101. package/lib/formatter/helpers/gherkin_document_parser.js +65 -65
  102. package/lib/formatter/helpers/index.d.ts +10 -10
  103. package/lib/formatter/helpers/index.js +51 -51
  104. package/lib/formatter/helpers/issue_helpers.d.ts +19 -19
  105. package/lib/formatter/helpers/issue_helpers.js +58 -58
  106. package/lib/formatter/helpers/keyword_type.d.ts +11 -11
  107. package/lib/formatter/helpers/keyword_type.js +31 -31
  108. package/lib/formatter/helpers/location_helpers.d.ts +2 -2
  109. package/lib/formatter/helpers/location_helpers.js +16 -16
  110. package/lib/formatter/helpers/pickle_parser.d.ts +17 -17
  111. package/lib/formatter/helpers/pickle_parser.js +27 -27
  112. package/lib/formatter/helpers/report_generator.d.ts +110 -91
  113. package/lib/formatter/helpers/report_generator.js +348 -250
  114. package/lib/formatter/helpers/report_generator.js.map +1 -1
  115. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
  116. package/lib/formatter/helpers/step_argument_formatter.js +47 -47
  117. package/lib/formatter/helpers/summary_helpers.d.ts +9 -9
  118. package/lib/formatter/helpers/summary_helpers.js +95 -95
  119. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -12
  120. package/lib/formatter/helpers/test_case_attempt_formatter.js +113 -113
  121. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -32
  122. package/lib/formatter/helpers/test_case_attempt_parser.js +134 -134
  123. package/lib/formatter/helpers/upload_serivce.d.ts +13 -9
  124. package/lib/formatter/helpers/upload_serivce.js +103 -46
  125. package/lib/formatter/helpers/upload_serivce.js.map +1 -1
  126. package/lib/formatter/helpers/uploader.d.ts +11 -0
  127. package/lib/formatter/helpers/uploader.js +78 -0
  128. package/lib/formatter/helpers/uploader.js.map +1 -0
  129. package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -23
  130. package/lib/formatter/helpers/usage_helpers/index.js +110 -110
  131. package/lib/formatter/html_formatter.d.ts +7 -7
  132. package/lib/formatter/html_formatter.js +29 -29
  133. package/lib/formatter/index.d.ts +53 -53
  134. package/lib/formatter/index.js +20 -20
  135. package/lib/formatter/json_formatter.d.ts +78 -78
  136. package/lib/formatter/json_formatter.js +229 -229
  137. package/lib/formatter/junit_formatter.d.ts +17 -17
  138. package/lib/formatter/junit_formatter.js +180 -180
  139. package/lib/formatter/message_formatter.d.ts +5 -5
  140. package/lib/formatter/message_formatter.js +14 -14
  141. package/lib/formatter/progress_bar_formatter.d.ts +18 -18
  142. package/lib/formatter/progress_bar_formatter.js +98 -98
  143. package/lib/formatter/progress_formatter.d.ts +9 -9
  144. package/lib/formatter/progress_formatter.js +58 -58
  145. package/lib/formatter/rerun_formatter.d.ts +13 -13
  146. package/lib/formatter/rerun_formatter.js +79 -79
  147. package/lib/formatter/snippets_formatter.d.ts +6 -6
  148. package/lib/formatter/snippets_formatter.js +60 -60
  149. package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -20
  150. package/lib/formatter/step_definition_snippet_builder/index.js +45 -45
  151. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -7
  152. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +45 -45
  153. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -16
  154. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +10 -10
  155. package/lib/formatter/summary_formatter.d.ts +14 -14
  156. package/lib/formatter/summary_formatter.js +67 -67
  157. package/lib/formatter/usage_formatter.d.ts +6 -6
  158. package/lib/formatter/usage_formatter.js +97 -97
  159. package/lib/formatter/usage_json_formatter.d.ts +7 -7
  160. package/lib/formatter/usage_json_formatter.js +33 -33
  161. package/lib/index.d.ts +58 -58
  162. package/lib/index.js +108 -108
  163. package/lib/logger.d.ts +5 -5
  164. package/lib/logger.js +2 -2
  165. package/lib/models/data_table.d.ts +10 -10
  166. package/lib/models/data_table.js +45 -45
  167. package/lib/models/definition.d.ts +55 -55
  168. package/lib/models/definition.js +21 -21
  169. package/lib/models/gherkin_step_keyword.d.ts +1 -1
  170. package/lib/models/gherkin_step_keyword.js +2 -2
  171. package/lib/models/pickle_order.d.ts +1 -1
  172. package/lib/models/pickle_order.js +2 -2
  173. package/lib/models/step_definition.d.ts +11 -11
  174. package/lib/models/step_definition.js +36 -36
  175. package/lib/models/test_case_hook_definition.d.ts +10 -10
  176. package/lib/models/test_case_hook_definition.js +26 -26
  177. package/lib/models/test_run_hook_definition.d.ts +3 -3
  178. package/lib/models/test_run_hook_definition.js +9 -9
  179. package/lib/models/test_step_hook_definition.d.ts +9 -9
  180. package/lib/models/test_step_hook_definition.js +25 -25
  181. package/lib/pickle_filter.d.ts +42 -42
  182. package/lib/pickle_filter.js +98 -98
  183. package/lib/plugin/index.d.ts +2 -2
  184. package/lib/plugin/index.js +18 -18
  185. package/lib/plugin/plugin_manager.d.ts +13 -13
  186. package/lib/plugin/plugin_manager.js +35 -35
  187. package/lib/plugin/types.d.ts +14 -14
  188. package/lib/plugin/types.js +2 -2
  189. package/lib/publish/http_stream.d.ts +30 -30
  190. package/lib/publish/http_stream.js +111 -111
  191. package/lib/publish/index.d.ts +2 -2
  192. package/lib/publish/index.js +4 -4
  193. package/lib/publish/publish_plugin.d.ts +2 -2
  194. package/lib/publish/publish_plugin.js +47 -47
  195. package/lib/runtime/assemble_test_cases.d.ts +13 -13
  196. package/lib/runtime/assemble_test_cases.js +87 -87
  197. package/lib/runtime/attachment_manager/index.d.ts +33 -33
  198. package/lib/runtime/attachment_manager/index.js +118 -118
  199. package/lib/runtime/format_error.d.ts +2 -2
  200. package/lib/runtime/format_error.js +35 -35
  201. package/lib/runtime/helpers.d.ts +6 -6
  202. package/lib/runtime/helpers.js +100 -100
  203. package/lib/runtime/index.d.ts +40 -40
  204. package/lib/runtime/index.js +75 -75
  205. package/lib/runtime/parallel/command_types.d.ts +32 -32
  206. package/lib/runtime/parallel/command_types.js +2 -2
  207. package/lib/runtime/parallel/coordinator.d.ts +72 -72
  208. package/lib/runtime/parallel/coordinator.js +221 -221
  209. package/lib/runtime/parallel/run_worker.d.ts +1 -1
  210. package/lib/runtime/parallel/run_worker.js +28 -28
  211. package/lib/runtime/parallel/worker.d.ts +26 -26
  212. package/lib/runtime/parallel/worker.js +86 -86
  213. package/lib/runtime/run_test_run_hooks.d.ts +3 -3
  214. package/lib/runtime/run_test_run_hooks.js +27 -27
  215. package/lib/runtime/step_runner.d.ts +16 -16
  216. package/lib/runtime/step_runner.js +87 -87
  217. package/lib/runtime/stopwatch.d.ts +12 -12
  218. package/lib/runtime/stopwatch.js +33 -33
  219. package/lib/runtime/test_case_runner.d.ts +54 -54
  220. package/lib/runtime/test_case_runner.js +267 -267
  221. package/lib/step_arguments.d.ts +6 -6
  222. package/lib/step_arguments.js +18 -18
  223. package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -3
  224. package/lib/support_code_library_builder/build_parameter_type.js +12 -12
  225. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -3
  226. package/lib/support_code_library_builder/get_definition_line_and_uri.js +28 -28
  227. package/lib/support_code_library_builder/index.d.ts +74 -74
  228. package/lib/support_code_library_builder/index.js +296 -296
  229. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -2
  230. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +15 -15
  231. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -7
  232. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +18 -18
  233. package/lib/support_code_library_builder/types.d.ts +88 -88
  234. package/lib/support_code_library_builder/types.js +2 -2
  235. package/lib/support_code_library_builder/validate_arguments.d.ts +12 -12
  236. package/lib/support_code_library_builder/validate_arguments.js +72 -72
  237. package/lib/support_code_library_builder/world.d.ts +18 -18
  238. package/lib/support_code_library_builder/world.js +10 -10
  239. package/lib/time.d.ts +18 -18
  240. package/lib/time.js +60 -60
  241. package/lib/try_require.d.ts +7 -7
  242. package/lib/try_require.js +22 -22
  243. package/lib/types/index.d.ts +4 -4
  244. package/lib/types/index.js +2 -2
  245. package/lib/uncaught_exception_manager.d.ts +7 -7
  246. package/lib/uncaught_exception_manager.js +11 -11
  247. package/lib/user_code_runner.d.ts +14 -14
  248. package/lib/user_code_runner.js +81 -81
  249. package/lib/value_checker.d.ts +3 -3
  250. package/lib/value_checker.js +18 -18
  251. package/lib/version.d.ts +1 -1
  252. package/lib/version.js +5 -5
  253. package/lib/version.js.map +1 -1
  254. package/package.json +4 -2
  255. package/lib/formatter/bvt_formatter.d.ts +0 -9
  256. package/lib/formatter/bvt_formatter.js +0 -63
  257. package/lib/formatter/bvt_formatter.js.map +0 -1
@@ -1,47 +1,104 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RunUploadService = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class RunUploadService {
9
- constructor(runsApiBaseURL, accessToken) {
10
- this.runsApiBaseURL = runsApiBaseURL;
11
- this.accessToken = accessToken;
12
- }
13
- async createRunDocument(name) {
14
- const runDocResult = await axios_1.default.post(this.runsApiBaseURL + "/cucumber-runs/create", {
15
- name,
16
- }, {
17
- headers: {
18
- Authorization: "Bearer " + this.accessToken,
19
- "x-source": "cucumber_js"
20
- },
21
- });
22
- if (runDocResult.status !== 200) {
23
- throw new Error("Failed to create run document in the server");
24
- }
25
- if (runDocResult.data.status !== true) {
26
- throw new Error("Failed to create run document in the server");
27
- }
28
- return runDocResult.data.run;
29
- }
30
- async upload(formData) {
31
- const response = await axios_1.default.post(this.runsApiBaseURL + "/cucumber-runs/upload", formData, {
32
- headers: {
33
- ...formData.getHeaders(),
34
- Authorization: "Bearer " + this.accessToken,
35
- "x-source": "cucumber_js"
36
- },
37
- });
38
- if (response.status !== 200) {
39
- throw new Error("Failed to upload run to the server");
40
- }
41
- if (response.data.status !== true) {
42
- throw new Error("Failed to upload run to the server");
43
- }
44
- }
45
- }
46
- exports.RunUploadService = RunUploadService;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RunUploadService = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const fs_1 = require("fs");
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ class RunUploadService {
11
+ constructor(runsApiBaseURL, accessToken) {
12
+ this.runsApiBaseURL = runsApiBaseURL;
13
+ this.accessToken = accessToken;
14
+ }
15
+ async createRunDocument(name) {
16
+ const runDocResult = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/create', {
17
+ name: name ? name : 'TEST',
18
+ }, {
19
+ headers: {
20
+ Authorization: 'Bearer ' + this.accessToken,
21
+ 'x-source': 'cucumber_js',
22
+ },
23
+ });
24
+ if (runDocResult.status !== 200) {
25
+ throw new Error('Failed to create run document in the server');
26
+ }
27
+ if (runDocResult.data.status !== true) {
28
+ throw new Error('Failed to create run document in the server');
29
+ }
30
+ return runDocResult.data.run;
31
+ }
32
+ async upload(formData) {
33
+ const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/upload', formData, {
34
+ headers: {
35
+ ...formData.getHeaders(),
36
+ Authorization: 'Bearer ' + this.accessToken,
37
+ 'x-source': 'cucumber_js',
38
+ },
39
+ });
40
+ if (response.status !== 200) {
41
+ throw new Error('Failed to upload run to the server');
42
+ }
43
+ if (response.data.status !== true) {
44
+ throw new Error('Failed to upload run to the server');
45
+ }
46
+ }
47
+ async getPreSignedUrls(fileUris, runId) {
48
+ const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/generateuploadurls', {
49
+ fileUris,
50
+ runId,
51
+ }, {
52
+ headers: {
53
+ Authorization: 'Bearer ' + this.accessToken,
54
+ 'x-source': 'cucumber_js',
55
+ },
56
+ });
57
+ if (response.status !== 200) {
58
+ throw new Error('Failed to get pre-signed urls for the files');
59
+ }
60
+ if (response.data.status !== true) {
61
+ throw new Error('Failed to get pre-signed urls for the files');
62
+ }
63
+ return response.data.uploadUrls;
64
+ }
65
+ async uploadFile(filePath, preSignedUrl) {
66
+ const fileStream = (0, fs_1.createReadStream)(filePath);
67
+ try {
68
+ const fileStats = await promises_1.default.stat(filePath);
69
+ const fileSize = fileStats.size;
70
+ await axios_1.default.put(preSignedUrl, fileStream, {
71
+ headers: {
72
+ 'Content-Type': 'application/octet-stream',
73
+ 'Content-Length': fileSize,
74
+ },
75
+ });
76
+ console.log('Uploaded successfully:\n', filePath);
77
+ }
78
+ catch (error) {
79
+ console.error('Error uploading file:', error);
80
+ }
81
+ finally {
82
+ fileStream.close();
83
+ }
84
+ }
85
+ async uploadComplete(runId, report) {
86
+ const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/uploadcomplete', {
87
+ runId,
88
+ report,
89
+ }, {
90
+ headers: {
91
+ Authorization: 'Bearer ' + this.accessToken,
92
+ 'x-source': 'cucumber_js',
93
+ },
94
+ });
95
+ if (response.status !== 200) {
96
+ throw new Error('Failed to mark run as complete');
97
+ }
98
+ if (response.data.status !== true) {
99
+ throw new Error('Failed to mark run as complete');
100
+ }
101
+ }
102
+ }
103
+ exports.RunUploadService = RunUploadService;
47
104
  //# sourceMappingURL=upload_serivce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,MAAM,gBAAgB;IAClB,YAAoB,cAAqB,EAAU,WAAkB;QAAjD,mBAAc,GAAd,cAAc,CAAO;QAAU,gBAAW,GAAX,WAAW,CAAO;IACrE,CAAC;IACD,KAAK,CAAC,iBAAiB,CAAC,IAAW;QACjC,MAAM,YAAY,GAAG,MAAM,eAAK,CAAC,IAAI,CACnC,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;YACE,IAAI;SACL,EACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAC,aAAa;aACzB;SACF,CACF,CAAC;QACF,IAAG,YAAY,CAAC,MAAM,KAAK,GAAG,EAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QACD,IAAG,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAC;YACnC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAA;IAC9B,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAiB;QAC1B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAAE,QAAQ,EAAE;YACvF,OAAO,EAAE;gBACP,GAAG,QAAQ,CAAC,UAAU,EAAE;gBACxB,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAC,aAAa;aACzB;SACF,CAAC,CAAA;QACF,IAAG,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAC;YACzB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QACD,IAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;IACP,CAAC;CACJ;AACO,4CAAgB","sourcesContent":["import axios from \"axios\";\r\nimport FormData from \"form-data\";\r\nclass RunUploadService {\r\n constructor(private runsApiBaseURL:string, private accessToken:string){\r\n }\r\n async createRunDocument(name:string){\r\n const runDocResult = await axios.post(\r\n this.runsApiBaseURL + \"/cucumber-runs/create\",\r\n {\r\n name,\r\n },\r\n {\r\n headers: {\r\n Authorization: \"Bearer \" + this.accessToken,\r\n \"x-source\":\"cucumber_js\"\r\n },\r\n }\r\n );\r\n if(runDocResult.status !== 200){\r\n throw new Error(\"Failed to create run document in the server\");\r\n }\r\n if(runDocResult.data.status !== true){\r\n throw new Error(\"Failed to create run document in the server\");\r\n }\r\n return runDocResult.data.run\r\n }\r\n async upload(formData:FormData){\r\n const response = await axios.post(this.runsApiBaseURL + \"/cucumber-runs/upload\", formData, {\r\n headers: {\r\n ...formData.getHeaders(),\r\n Authorization: \"Bearer \" + this.accessToken,\r\n \"x-source\":\"cucumber_js\"\r\n },\r\n })\r\n if(response.status !== 200){\r\n throw new Error(\"Failed to upload run to the server\");\r\n }\r\n if(response.data.status !== true){\r\n throw new Error(\"Failed to upload run to the server\");\r\n }\r\n }\r\n}\r\nexport {RunUploadService}"]}
1
+ {"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAEzB,2BAAqC;AACrC,2DAA4B;AAE5B,MAAM,gBAAgB;IACpB,YAAoB,cAAsB,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AAc,CAAC,KAAa,EAAE,MAAkB;QACpD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,IAAI,CAAC,cAAc,GAAG,+BAA+B,EACrD;YACE,KAAK;YACL,MAAM;SACP,EACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAE,aAAa;aAC1B;SACF,CACF,CAAA;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["import axios from 'axios'\nimport FormData from 'form-data'\nimport { createReadStream } from 'fs'\nimport fs from 'fs/promises'\nimport { JsonReport } from './report_generator'\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string) {\n const runDocResult = await axios.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n }\n async upload(formData: FormData) {\n const response = await axios.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n const response = await axios.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadFile(filePath: string, preSignedUrl: string) {\n const fileStream = createReadStream(filePath)\n\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axios.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n console.log('Uploaded successfully:\\n', filePath)\n } catch (error) {\n console.error('Error uploading file:', error)\n } finally {\n fileStream.close()\n }\n }\n async uploadComplete(runId: string, report: JsonReport) {\n const response = await axios.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadcomplete',\n {\n runId,\n report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n }\n}\n\nexport { RunUploadService }\n"]}
@@ -0,0 +1,11 @@
1
+ import ReportGenerator, { JsonReport } from './report_generator';
2
+ export default class ReportUploader {
3
+ private uploadService;
4
+ private reportGenerator;
5
+ constructor(reportGenerator: ReportGenerator);
6
+ uploadRun(report: JsonReport, runName: string): Promise<{
7
+ runId: any;
8
+ projectId: any;
9
+ }>;
10
+ createZip(reportFolder: string | null, report: JsonReport): Promise<string>;
11
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a, _b;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const upload_serivce_1 = require("./upload_serivce");
8
+ const form_data_1 = __importDefault(require("form-data"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const jszip_1 = __importDefault(require("jszip"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const URL = process.env.NODE_ENV_BLINQ === 'dev'
13
+ ? 'https://dev.api.blinq.io/api/runs'
14
+ : process.env.NODE_ENV_BLINQ === 'local'
15
+ ? 'http://localhost:5001/api/runs'
16
+ : 'https://api.blinq.io/api/runs';
17
+ const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
18
+ const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
19
+ class ReportUploader {
20
+ constructor(reportGenerator) {
21
+ this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
22
+ if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {
23
+ throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set');
24
+ }
25
+ this.reportGenerator = reportGenerator;
26
+ }
27
+ async uploadRun(report, runName) {
28
+ const runDoc = await this.uploadService.createRunDocument(runName);
29
+ const runDocId = runDoc._id;
30
+ const reportFolder = this.reportGenerator.reportFolder;
31
+ if (!fs_1.default.existsSync(reportFolder)) {
32
+ fs_1.default.mkdirSync(reportFolder);
33
+ }
34
+ if (process.env.NODE_ENV_BLINQ === 'local') {
35
+ const formData = new form_data_1.default();
36
+ const zipPath = await this.createZip(reportFolder, report);
37
+ formData.append(runDocId, fs_1.default.readFileSync(zipPath), 'report.zip');
38
+ await this.uploadService.upload(formData);
39
+ }
40
+ else {
41
+ const fileUris = getFileUrisScreenShotDir(reportFolder);
42
+ try {
43
+ const preSignedUrls = await this.uploadService.getPreSignedUrls(fileUris, runDocId);
44
+ await Promise.all(fileUris
45
+ .filter((fileUri) => preSignedUrls[fileUri])
46
+ .map((fileUri) => {
47
+ return this.uploadService.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
48
+ }));
49
+ await this.uploadService.uploadComplete(runDocId, report);
50
+ }
51
+ catch (err) {
52
+ throw new Error('Failed to upload all the files');
53
+ }
54
+ }
55
+ return { runId: runDoc._id, projectId: runDoc.project_id };
56
+ }
57
+ async createZip(reportFolder, report) {
58
+ const zip = new jszip_1.default();
59
+ zip.file('report.json', JSON.stringify(report, null, 2));
60
+ const folder = zip.folder('screenshots');
61
+ const files = fs_1.default.readdirSync(path_1.default.join(reportFolder, 'screenshots'));
62
+ files.forEach((file) => {
63
+ folder.file(file, fs_1.default.readFileSync(path_1.default.join(reportFolder, 'screenshots', file)));
64
+ });
65
+ const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' });
66
+ // save zip file
67
+ const zipPath = path_1.default.join(reportFolder, 'report.zip');
68
+ fs_1.default.writeFileSync(zipPath, zipBuffer);
69
+ fs_1.default.writeFileSync(path_1.default.join(reportFolder, 'report.json'), JSON.stringify(report, null, 2));
70
+ return zipPath;
71
+ }
72
+ }
73
+ exports.default = ReportUploader;
74
+ const getFileUrisScreenShotDir = (reportFolder) => {
75
+ const files = fs_1.default.readdirSync(path_1.default.join(reportFolder, 'screenshots'));
76
+ return files.map((file) => ['screenshots', file].join('/'));
77
+ };
78
+ //# sourceMappingURL=uploader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;AACA,qDAAmD;AAEnD,0DAAgC;AAChC,4CAAmB;AACnB,kDAAyB;AACzB,gDAAuB;AACvB,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;QACxC,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,+BAA+B,CAAA;AA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ACT,IAAI,EACJ,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC,CAC9D,CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QACjE,gBAAgB;QAChB,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;QACrD,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QACpC,YAAE,CAAC,aAAa,CACd,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,EACtC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAChC,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAtED,iCAsEC;AACD,MAAM,wBAAwB,GAAG,CAAC,YAAoB,EAAE,EAAE;IACxD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAA;IAEpE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7D,CAAC,CAAA","sourcesContent":["import ReportGenerator, { JsonReport } from './report_generator'\nimport { RunUploadService } from './upload_serivce'\n\nimport FormData from 'form-data'\nimport fs from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : 'https://api.blinq.io/api/runs'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(runName)\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n if (process.env.NODE_ENV_BLINQ === 'local') {\n const formData = new FormData()\n const zipPath = await this.createZip(reportFolder, report)\n formData.append(runDocId, fs.readFileSync(zipPath), 'report.zip')\n await this.uploadService.upload(formData)\n } else {\n const fileUris = getFileUrisScreenShotDir(reportFolder)\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n await Promise.all(\n fileUris\n .filter((fileUri) => preSignedUrls[fileUri])\n .map((fileUri) => {\n return this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n })\n )\n await this.uploadService.uploadComplete(runDocId, report)\n } catch (err) {\n throw new Error('Failed to upload all the files')\n }\n }\n return { runId: runDoc._id, projectId: runDoc.project_id }\n }\n async createZip(reportFolder: string | null, report: JsonReport) {\n const zip = new JSZip()\n zip.file('report.json', JSON.stringify(report, null, 2))\n const folder = zip.folder('screenshots')\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n files.forEach((file) => {\n folder.file(\n file,\n fs.readFileSync(path.join(reportFolder, 'screenshots', file))\n )\n })\n const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })\n // save zip file\n const zipPath = path.join(reportFolder, 'report.zip')\n fs.writeFileSync(zipPath, zipBuffer)\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\n }\n}\nconst getFileUrisScreenShotDir = (reportFolder: string) => {\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n\n return files.map((file) => ['screenshots', file].join('/'))\n}\n"]}
@@ -1,23 +1,23 @@
1
- import * as messages from '@cucumber/messages';
2
- import StepDefinition from '../../../models/step_definition';
3
- import EventDataCollector from '../event_data_collector';
4
- export interface IUsageMatch {
5
- duration?: messages.Duration;
6
- line: number;
7
- text: string;
8
- uri: string;
9
- }
10
- export interface IUsage {
11
- code: string;
12
- line: number;
13
- matches: IUsageMatch[];
14
- meanDuration?: messages.Duration;
15
- pattern: string;
16
- patternType: string;
17
- uri: string;
18
- }
19
- export interface IGetUsageRequest {
20
- eventDataCollector: EventDataCollector;
21
- stepDefinitions: StepDefinition[];
22
- }
23
- export declare function getUsage({ stepDefinitions, eventDataCollector, }: IGetUsageRequest): IUsage[];
1
+ import * as messages from '@cucumber/messages';
2
+ import StepDefinition from '../../../models/step_definition';
3
+ import EventDataCollector from '../event_data_collector';
4
+ export interface IUsageMatch {
5
+ duration?: messages.Duration;
6
+ line: number;
7
+ text: string;
8
+ uri: string;
9
+ }
10
+ export interface IUsage {
11
+ code: string;
12
+ line: number;
13
+ matches: IUsageMatch[];
14
+ meanDuration?: messages.Duration;
15
+ pattern: string;
16
+ patternType: string;
17
+ uri: string;
18
+ }
19
+ export interface IGetUsageRequest {
20
+ eventDataCollector: EventDataCollector;
21
+ stepDefinitions: StepDefinition[];
22
+ }
23
+ export declare function getUsage({ stepDefinitions, eventDataCollector, }: IGetUsageRequest): IUsage[];
@@ -1,111 +1,111 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getUsage = void 0;
27
- const pickle_parser_1 = require("../pickle_parser");
28
- const gherkin_document_parser_1 = require("../gherkin_document_parser");
29
- const messages = __importStar(require("@cucumber/messages"));
30
- const value_checker_1 = require("../../../value_checker");
31
- function buildEmptyMapping(stepDefinitions) {
32
- const mapping = {};
33
- stepDefinitions.forEach((stepDefinition) => {
34
- mapping[stepDefinition.id] = {
35
- code: stepDefinition.unwrappedCode.toString(),
36
- line: stepDefinition.line,
37
- pattern: stepDefinition.expression.source,
38
- patternType: stepDefinition.expression.constructor.name,
39
- matches: [],
40
- uri: stepDefinition.uri,
41
- };
42
- });
43
- return mapping;
44
- }
45
- const unexecutedStatuses = [
46
- messages.TestStepResultStatus.AMBIGUOUS,
47
- messages.TestStepResultStatus.SKIPPED,
48
- messages.TestStepResultStatus.UNDEFINED,
49
- ];
50
- function buildMapping({ stepDefinitions, eventDataCollector, }) {
51
- const mapping = buildEmptyMapping(stepDefinitions);
52
- eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {
53
- const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(testCaseAttempt.pickle);
54
- const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(testCaseAttempt.gherkinDocument);
55
- testCaseAttempt.testCase.testSteps.forEach((testStep) => {
56
- if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId) &&
57
- testStep.stepDefinitionIds.length === 1) {
58
- const stepDefinitionId = testStep.stepDefinitionIds[0];
59
- const pickleStep = pickleStepMap[testStep.pickleStepId];
60
- const gherkinStep = gherkinStepMap[pickleStep.astNodeIds[0]];
61
- const match = {
62
- line: gherkinStep.location.line,
63
- text: pickleStep.text,
64
- uri: testCaseAttempt.pickle.uri,
65
- };
66
- const { duration, status } = testCaseAttempt.stepResults[testStep.id];
67
- if (!unexecutedStatuses.includes(status) && (0, value_checker_1.doesHaveValue)(duration)) {
68
- match.duration = duration;
69
- }
70
- if ((0, value_checker_1.doesHaveValue)(mapping[stepDefinitionId])) {
71
- mapping[stepDefinitionId].matches.push(match);
72
- }
73
- }
74
- });
75
- });
76
- return mapping;
77
- }
78
- function normalizeDuration(duration) {
79
- if (duration == null) {
80
- return Number.MIN_SAFE_INTEGER;
81
- }
82
- return messages.TimeConversion.durationToMilliseconds(duration);
83
- }
84
- function buildResult(mapping) {
85
- return Object.keys(mapping)
86
- .map((stepDefinitionId) => {
87
- const { matches, ...rest } = mapping[stepDefinitionId];
88
- const sortedMatches = matches.sort((a, b) => {
89
- if (a.duration === b.duration) {
90
- return a.text < b.text ? -1 : 1;
91
- }
92
- return normalizeDuration(b.duration) - normalizeDuration(a.duration);
93
- });
94
- const result = { matches: sortedMatches, ...rest };
95
- const durations = matches
96
- .filter((m) => m.duration != null)
97
- .map((m) => m.duration);
98
- if (durations.length > 0) {
99
- const totalMilliseconds = durations.reduce((acc, x) => acc + messages.TimeConversion.durationToMilliseconds(x), 0);
100
- result.meanDuration = messages.TimeConversion.millisecondsToDuration(totalMilliseconds / durations.length);
101
- }
102
- return result;
103
- })
104
- .sort((a, b) => normalizeDuration(b.meanDuration) - normalizeDuration(a.meanDuration));
105
- }
106
- function getUsage({ stepDefinitions, eventDataCollector, }) {
107
- const mapping = buildMapping({ stepDefinitions, eventDataCollector });
108
- return buildResult(mapping);
109
- }
110
- exports.getUsage = getUsage;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getUsage = void 0;
27
+ const pickle_parser_1 = require("../pickle_parser");
28
+ const gherkin_document_parser_1 = require("../gherkin_document_parser");
29
+ const messages = __importStar(require("@cucumber/messages"));
30
+ const value_checker_1 = require("../../../value_checker");
31
+ function buildEmptyMapping(stepDefinitions) {
32
+ const mapping = {};
33
+ stepDefinitions.forEach((stepDefinition) => {
34
+ mapping[stepDefinition.id] = {
35
+ code: stepDefinition.unwrappedCode.toString(),
36
+ line: stepDefinition.line,
37
+ pattern: stepDefinition.expression.source,
38
+ patternType: stepDefinition.expression.constructor.name,
39
+ matches: [],
40
+ uri: stepDefinition.uri,
41
+ };
42
+ });
43
+ return mapping;
44
+ }
45
+ const unexecutedStatuses = [
46
+ messages.TestStepResultStatus.AMBIGUOUS,
47
+ messages.TestStepResultStatus.SKIPPED,
48
+ messages.TestStepResultStatus.UNDEFINED,
49
+ ];
50
+ function buildMapping({ stepDefinitions, eventDataCollector, }) {
51
+ const mapping = buildEmptyMapping(stepDefinitions);
52
+ eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {
53
+ const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(testCaseAttempt.pickle);
54
+ const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(testCaseAttempt.gherkinDocument);
55
+ testCaseAttempt.testCase.testSteps.forEach((testStep) => {
56
+ if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId) &&
57
+ testStep.stepDefinitionIds.length === 1) {
58
+ const stepDefinitionId = testStep.stepDefinitionIds[0];
59
+ const pickleStep = pickleStepMap[testStep.pickleStepId];
60
+ const gherkinStep = gherkinStepMap[pickleStep.astNodeIds[0]];
61
+ const match = {
62
+ line: gherkinStep.location.line,
63
+ text: pickleStep.text,
64
+ uri: testCaseAttempt.pickle.uri,
65
+ };
66
+ const { duration, status } = testCaseAttempt.stepResults[testStep.id];
67
+ if (!unexecutedStatuses.includes(status) && (0, value_checker_1.doesHaveValue)(duration)) {
68
+ match.duration = duration;
69
+ }
70
+ if ((0, value_checker_1.doesHaveValue)(mapping[stepDefinitionId])) {
71
+ mapping[stepDefinitionId].matches.push(match);
72
+ }
73
+ }
74
+ });
75
+ });
76
+ return mapping;
77
+ }
78
+ function normalizeDuration(duration) {
79
+ if (duration == null) {
80
+ return Number.MIN_SAFE_INTEGER;
81
+ }
82
+ return messages.TimeConversion.durationToMilliseconds(duration);
83
+ }
84
+ function buildResult(mapping) {
85
+ return Object.keys(mapping)
86
+ .map((stepDefinitionId) => {
87
+ const { matches, ...rest } = mapping[stepDefinitionId];
88
+ const sortedMatches = matches.sort((a, b) => {
89
+ if (a.duration === b.duration) {
90
+ return a.text < b.text ? -1 : 1;
91
+ }
92
+ return normalizeDuration(b.duration) - normalizeDuration(a.duration);
93
+ });
94
+ const result = { matches: sortedMatches, ...rest };
95
+ const durations = matches
96
+ .filter((m) => m.duration != null)
97
+ .map((m) => m.duration);
98
+ if (durations.length > 0) {
99
+ const totalMilliseconds = durations.reduce((acc, x) => acc + messages.TimeConversion.durationToMilliseconds(x), 0);
100
+ result.meanDuration = messages.TimeConversion.millisecondsToDuration(totalMilliseconds / durations.length);
101
+ }
102
+ return result;
103
+ })
104
+ .sort((a, b) => normalizeDuration(b.meanDuration) - normalizeDuration(a.meanDuration));
105
+ }
106
+ function getUsage({ stepDefinitions, eventDataCollector, }) {
107
+ const mapping = buildMapping({ stepDefinitions, eventDataCollector });
108
+ return buildResult(mapping);
109
+ }
110
+ exports.getUsage = getUsage;
111
111
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
- import Formatter, { IFormatterOptions } from '.';
2
- export default class HtmlFormatter extends Formatter {
3
- private readonly _htmlStream;
4
- static readonly documentation: string;
5
- constructor(options: IFormatterOptions);
6
- finished(): Promise<void>;
7
- }
1
+ import Formatter, { IFormatterOptions } from '.';
2
+ export default class HtmlFormatter extends Formatter {
3
+ private readonly _htmlStream;
4
+ static readonly documentation: string;
5
+ constructor(options: IFormatterOptions);
6
+ finished(): Promise<void>;
7
+ }
@@ -1,30 +1,30 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const _1 = __importDefault(require("."));
7
- const resolve_pkg_1 = __importDefault(require("resolve-pkg"));
8
- const html_formatter_1 = __importDefault(require("@cucumber/html-formatter"));
9
- const stream_1 = require("stream");
10
- const util_1 = require("util");
11
- class HtmlFormatter extends _1.default {
12
- constructor(options) {
13
- super(options);
14
- this._htmlStream = new html_formatter_1.default((0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
15
- '/dist/main.css', (0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
16
- '/dist/main.js');
17
- options.eventBroadcaster.on('envelope', (envelope) => {
18
- this._htmlStream.write(envelope);
19
- });
20
- this._htmlStream.on('data', (chunk) => this.log(chunk));
21
- }
22
- async finished() {
23
- this._htmlStream.end();
24
- await (0, util_1.promisify)(stream_1.finished)(this._htmlStream);
25
- await super.finished();
26
- }
27
- }
28
- exports.default = HtmlFormatter;
29
- HtmlFormatter.documentation = 'Outputs HTML report';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const _1 = __importDefault(require("."));
7
+ const resolve_pkg_1 = __importDefault(require("resolve-pkg"));
8
+ const html_formatter_1 = __importDefault(require("@cucumber/html-formatter"));
9
+ const stream_1 = require("stream");
10
+ const util_1 = require("util");
11
+ class HtmlFormatter extends _1.default {
12
+ constructor(options) {
13
+ super(options);
14
+ this._htmlStream = new html_formatter_1.default((0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
15
+ '/dist/main.css', (0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
16
+ '/dist/main.js');
17
+ options.eventBroadcaster.on('envelope', (envelope) => {
18
+ this._htmlStream.write(envelope);
19
+ });
20
+ this._htmlStream.on('data', (chunk) => this.log(chunk));
21
+ }
22
+ async finished() {
23
+ this._htmlStream.end();
24
+ await (0, util_1.promisify)(stream_1.finished)(this._htmlStream);
25
+ await super.finished();
26
+ }
27
+ }
28
+ exports.default = HtmlFormatter;
29
+ HtmlFormatter.documentation = 'Outputs HTML report';
30
30
  //# sourceMappingURL=html_formatter.js.map