@cucumber/cucumber 7.2.0 → 7.3.2

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 (137) hide show
  1. package/lib/cli/argv_parser.d.ts +0 -1
  2. package/lib/cli/argv_parser.js +0 -1
  3. package/lib/cli/argv_parser.js.map +1 -1
  4. package/lib/cli/configuration_builder.d.ts +0 -1
  5. package/lib/cli/configuration_builder.js +5 -5
  6. package/lib/cli/configuration_builder.js.map +1 -1
  7. package/lib/cli/helpers.js +41 -22
  8. package/lib/cli/helpers.js.map +1 -1
  9. package/lib/cli/index.d.ts +1 -3
  10. package/lib/cli/index.js +27 -30
  11. package/lib/cli/index.js.map +1 -1
  12. package/lib/cli/profile_loader.d.ts +2 -5
  13. package/lib/cli/profile_loader.js +2 -3
  14. package/lib/cli/profile_loader.js.map +1 -1
  15. package/lib/cli/publish_banner.js +1 -1
  16. package/lib/cli/publish_banner.js.map +1 -1
  17. package/lib/formatter/builder.d.ts +4 -8
  18. package/lib/formatter/builder.js +17 -32
  19. package/lib/formatter/builder.js.map +1 -1
  20. package/lib/formatter/get_color_fns.d.ts +6 -2
  21. package/lib/formatter/get_color_fns.js +18 -12
  22. package/lib/formatter/get_color_fns.js.map +1 -1
  23. package/lib/formatter/helpers/event_data_collector.d.ts +14 -17
  24. package/lib/formatter/helpers/event_data_collector.js +14 -8
  25. package/lib/formatter/helpers/event_data_collector.js.map +1 -1
  26. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
  27. package/lib/formatter/helpers/gherkin_document_parser.js +1 -4
  28. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
  29. package/lib/formatter/helpers/issue_helpers.d.ts +6 -6
  30. package/lib/formatter/helpers/issue_helpers.js +5 -6
  31. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  32. package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
  33. package/lib/formatter/helpers/pickle_parser.js.map +1 -1
  34. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
  35. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
  36. package/lib/formatter/helpers/summary_helpers.d.ts +2 -2
  37. package/lib/formatter/helpers/summary_helpers.js +32 -14
  38. package/lib/formatter/helpers/summary_helpers.js.map +1 -1
  39. package/lib/formatter/helpers/test_case_attempt_formatter.js +33 -14
  40. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  41. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +5 -5
  42. package/lib/formatter/helpers/test_case_attempt_parser.js +27 -9
  43. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  44. package/lib/formatter/helpers/usage_helpers/index.d.ts +3 -3
  45. package/lib/formatter/helpers/usage_helpers/index.js +44 -15
  46. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  47. package/lib/formatter/html_formatter.js +1 -1
  48. package/lib/formatter/html_formatter.js.map +1 -1
  49. package/lib/formatter/http_stream.js +1 -1
  50. package/lib/formatter/http_stream.js.map +1 -1
  51. package/lib/formatter/json_formatter.d.ts +21 -27
  52. package/lib/formatter/json_formatter.js +50 -23
  53. package/lib/formatter/json_formatter.js.map +1 -1
  54. package/lib/formatter/message_formatter.js +1 -1
  55. package/lib/formatter/message_formatter.js.map +1 -1
  56. package/lib/formatter/progress_bar_formatter.d.ts +6 -6
  57. package/lib/formatter/progress_bar_formatter.js +3 -3
  58. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  59. package/lib/formatter/progress_formatter.d.ts +2 -2
  60. package/lib/formatter/progress_formatter.js +29 -10
  61. package/lib/formatter/progress_formatter.js.map +1 -1
  62. package/lib/formatter/rerun_formatter.js +22 -4
  63. package/lib/formatter/rerun_formatter.js.map +1 -1
  64. package/lib/formatter/snippets_formatter.js +21 -2
  65. package/lib/formatter/snippets_formatter.js.map +1 -1
  66. package/lib/formatter/step_definition_snippet_builder/index.d.ts +3 -3
  67. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
  68. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
  69. package/lib/formatter/summary_formatter.d.ts +2 -2
  70. package/lib/formatter/summary_formatter.js.map +1 -1
  71. package/lib/formatter/usage_formatter.js +22 -3
  72. package/lib/formatter/usage_formatter.js.map +1 -1
  73. package/lib/formatter/usage_json_formatter.js.map +1 -1
  74. package/lib/index.d.ts +14 -12
  75. package/lib/index.js +3 -3
  76. package/lib/index.js.map +1 -1
  77. package/lib/models/data_table.d.ts +3 -4
  78. package/lib/models/data_table.js.map +1 -1
  79. package/lib/models/definition.d.ts +2 -2
  80. package/lib/models/definition.js.map +1 -1
  81. package/lib/models/test_case_hook_definition.d.ts +2 -2
  82. package/lib/models/test_case_hook_definition.js.map +1 -1
  83. package/lib/models/test_step_hook_definition.d.ts +2 -2
  84. package/lib/models/test_step_hook_definition.js.map +1 -1
  85. package/lib/pickle_filter.d.ts +9 -11
  86. package/lib/pickle_filter.js +4 -4
  87. package/lib/pickle_filter.js.map +1 -1
  88. package/lib/runtime/assemble_test_cases.d.ts +13 -0
  89. package/lib/runtime/assemble_test_cases.js +88 -0
  90. package/lib/runtime/assemble_test_cases.js.map +1 -0
  91. package/lib/runtime/attachment_manager/index.d.ts +2 -2
  92. package/lib/runtime/attachment_manager/index.js +23 -4
  93. package/lib/runtime/attachment_manager/index.js.map +1 -1
  94. package/lib/runtime/helpers.d.ts +2 -2
  95. package/lib/runtime/helpers.js.map +1 -1
  96. package/lib/runtime/index.d.ts +4 -3
  97. package/lib/runtime/index.js +31 -13
  98. package/lib/runtime/index.js.map +1 -1
  99. package/lib/runtime/parallel/command_types.d.ts +10 -9
  100. package/lib/runtime/parallel/command_types.js.map +1 -1
  101. package/lib/runtime/parallel/coordinator.d.ts +10 -9
  102. package/lib/runtime/parallel/coordinator.js +54 -43
  103. package/lib/runtime/parallel/coordinator.js.map +1 -1
  104. package/lib/runtime/parallel/worker.d.ts +2 -2
  105. package/lib/runtime/parallel/worker.js +8 -14
  106. package/lib/runtime/parallel/worker.js.map +1 -1
  107. package/lib/runtime/step_runner.d.ts +3 -3
  108. package/lib/runtime/step_runner.js +16 -12
  109. package/lib/runtime/step_runner.js.map +1 -1
  110. package/lib/runtime/stopwatch.d.ts +4 -4
  111. package/lib/runtime/stopwatch.js +21 -2
  112. package/lib/runtime/stopwatch.js.map +1 -1
  113. package/lib/runtime/{pickle_runner.d.ts → test_case_runner.d.ts} +16 -32
  114. package/lib/runtime/{pickle_runner.js → test_case_runner.js} +104 -147
  115. package/lib/runtime/test_case_runner.js.map +1 -0
  116. package/lib/step_arguments.d.ts +4 -4
  117. package/lib/step_arguments.js.map +1 -1
  118. package/lib/support_code_library_builder/index.d.ts +9 -7
  119. package/lib/support_code_library_builder/index.js +11 -10
  120. package/lib/support_code_library_builder/index.js.map +1 -1
  121. package/lib/support_code_library_builder/types.d.ts +21 -23
  122. package/lib/support_code_library_builder/types.js.map +1 -1
  123. package/lib/support_code_library_builder/validate_arguments.js +8 -8
  124. package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
  125. package/lib/support_code_library_builder/world.d.ts +7 -1
  126. package/lib/support_code_library_builder/world.js.map +1 -1
  127. package/lib/time.d.ts +2 -10
  128. package/lib/time.js +24 -48
  129. package/lib/time.js.map +1 -1
  130. package/package.json +38 -40
  131. package/CHANGELOG.md +0 -1874
  132. package/lib/importers.js +0 -17
  133. package/lib/runtime/pickle_runner.js.map +0 -1
  134. package/lib/status.d.ts +0 -3
  135. package/lib/status.js +0 -5
  136. package/lib/status.js.map +0 -1
  137. package/lib/wrapper.mjs +0 -38
@@ -1,4 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __rest = (this && this.__rest) || function (s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ };
2
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
34
  };
@@ -6,10 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.getUsage = void 0;
7
37
  const lodash_1 = __importDefault(require("lodash"));
8
38
  const pickle_parser_1 = require("../pickle_parser");
9
- const path_1 = __importDefault(require("path"));
10
39
  const gherkin_document_parser_1 = require("../gherkin_document_parser");
11
- const time_1 = require("../../../time");
12
- const messages_1 = require("@cucumber/messages");
40
+ const messages = __importStar(require("@cucumber/messages"));
13
41
  const value_checker_1 = require("../../../value_checker");
14
42
  function buildEmptyMapping(stepDefinitions) {
15
43
  const mapping = {};
@@ -25,13 +53,18 @@ function buildEmptyMapping(stepDefinitions) {
25
53
  });
26
54
  return mapping;
27
55
  }
56
+ const unexecutedStatuses = [
57
+ messages.TestStepResultStatus.AMBIGUOUS,
58
+ messages.TestStepResultStatus.SKIPPED,
59
+ messages.TestStepResultStatus.UNDEFINED,
60
+ ];
28
61
  function buildMapping({ cwd, stepDefinitions, eventDataCollector, }) {
29
62
  const mapping = buildEmptyMapping(stepDefinitions);
30
63
  lodash_1.default.each(eventDataCollector.getTestCaseAttempts(), (testCaseAttempt) => {
31
64
  const pickleStepMap = pickle_parser_1.getPickleStepMap(testCaseAttempt.pickle);
32
65
  const gherkinStepMap = gherkin_document_parser_1.getGherkinStepMap(testCaseAttempt.gherkinDocument);
33
66
  testCaseAttempt.testCase.testSteps.forEach((testStep) => {
34
- if (testStep.pickleStepId !== '' &&
67
+ if (value_checker_1.doesHaveValue(testStep.pickleStepId) &&
35
68
  testStep.stepDefinitionIds.length === 1) {
36
69
  const stepDefinitionId = testStep.stepDefinitionIds[0];
37
70
  const pickleStep = pickleStepMap[testStep.pickleStepId];
@@ -39,15 +72,10 @@ function buildMapping({ cwd, stepDefinitions, eventDataCollector, }) {
39
72
  const match = {
40
73
  line: gherkinStep.location.line,
41
74
  text: pickleStep.text,
42
- uri: path_1.default.relative(cwd, testCaseAttempt.pickle.uri),
75
+ uri: testCaseAttempt.pickle.uri,
43
76
  };
44
77
  const { duration, status } = testCaseAttempt.stepResults[testStep.id];
45
- if (![
46
- messages_1.messages.TestStepFinished.TestStepResult.Status.AMBIGUOUS,
47
- messages_1.messages.TestStepFinished.TestStepResult.Status.SKIPPED,
48
- messages_1.messages.TestStepFinished.TestStepResult.Status.UNDEFINED,
49
- ].includes(status) &&
50
- value_checker_1.doesHaveValue(duration)) {
78
+ if (!unexecutedStatuses.includes(status) && value_checker_1.doesHaveValue(duration)) {
51
79
  match.duration = duration;
52
80
  }
53
81
  if (value_checker_1.doesHaveValue(mapping[stepDefinitionId])) {
@@ -60,24 +88,25 @@ function buildMapping({ cwd, stepDefinitions, eventDataCollector, }) {
60
88
  }
61
89
  function invertDuration(duration) {
62
90
  if (value_checker_1.doesHaveValue(duration)) {
63
- return -1 * time_1.durationToMilliseconds(duration);
91
+ return -1 * messages.TimeConversion.durationToMilliseconds(duration);
64
92
  }
65
93
  return 1;
66
94
  }
67
95
  function buildResult(mapping) {
68
96
  return lodash_1.default.chain(mapping)
69
- .map(({ matches, ...rest }) => {
97
+ .map((_a) => {
98
+ var { matches } = _a, rest = __rest(_a, ["matches"]);
70
99
  const sortedMatches = lodash_1.default.sortBy(matches, [
71
100
  (match) => invertDuration(match.duration),
72
101
  'text',
73
102
  ]);
74
- const result = { matches: sortedMatches, ...rest };
103
+ const result = Object.assign({ matches: sortedMatches }, rest);
75
104
  const durations = lodash_1.default.chain(matches)
76
105
  .map((m) => m.duration)
77
106
  .compact()
78
107
  .value();
79
108
  if (durations.length > 0) {
80
- result.meanDuration = time_1.millisecondsToDuration(lodash_1.default.meanBy(durations, (d) => time_1.durationToMilliseconds(d)));
109
+ result.meanDuration = messages.TimeConversion.millisecondsToDuration(lodash_1.default.meanBy(durations, (d) => messages.TimeConversion.durationToMilliseconds(d)));
81
110
  }
82
111
  return result;
83
112
  })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/formatter/helpers/usage_helpers/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsC;AACtC,oDAAmD;AACnD,gDAAuB;AACvB,wEAA8D;AAC9D,wCAA8E;AAC9E,iDAA6C;AAE7C,0DAAsD;AA0BtD,SAAS,iBAAiB,CACxB,eAAiC;IAEjC,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;QACzC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG;YAC3B,IAAI,EAAE,cAAc,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC7C,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,MAAM;YACzC,WAAW,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI;YACvD,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,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Q,CAAC;aACnC,OAAO,EAAE;aACT,KAAK,EAAE,CAAA;QACV,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,MAAM,CAAC,YAAY,GAAG,6BAAsB,CAC1C,gBAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAqB,EAAE,EAAE,CAC5C,6BAAsB,CAAC,CAAC,CAAC,CAC1B,CACF,CAAA;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SAC7D,KAAK,EAAE,CAAA;AACZ,CAAC;AAED,SAAgB,QAAQ,CAAC,EACvB,GAAG,EACH,eAAe,EACf,kBAAkB,GACD;IACjB,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAA;IAC1E,OAAO,WAAW,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAPD,4BAOC","sourcesContent":["import _, { Dictionary } from 'lodash'\nimport { getPickleStepMap } from '../pickle_parser'\nimport path from 'path'\nimport { getGherkinStepMap } from '../gherkin_document_parser'\nimport { durationToMilliseconds, millisecondsToDuration } from '../../../time'\nimport { messages } from '@cucumber/messages'\nimport StepDefinition from '../../../models/step_definition'\nimport { doesHaveValue } from '../../../value_checker'\nimport EventDataCollector from '../event_data_collector'\n\nexport interface IUsageMatch {\n duration?: messages.IDuration\n line: number\n text: string\n uri: string\n}\n\nexport interface IUsage {\n code: string\n line: number\n matches: IUsageMatch[]\n meanDuration?: messages.IDuration\n pattern: string\n patternType: string\n uri: string\n}\n\nexport interface IGetUsageRequest {\n cwd: string\n eventDataCollector: EventDataCollector\n stepDefinitions: StepDefinition[]\n}\n\nfunction buildEmptyMapping(\n stepDefinitions: StepDefinition[]\n): Dictionary<IUsage> {\n const mapping: Dictionary<IUsage> = {}\n stepDefinitions.forEach((stepDefinition) => {\n mapping[stepDefinition.id] = {\n code: stepDefinition.unwrappedCode.toString(),\n line: stepDefinition.line,\n pattern: stepDefinition.expression.source,\n patternType: stepDefinition.expression.constructor.name,\n matches: [],\n uri: stepDefinition.uri,\n }\n })\n return mapping\n}\n\nfunction buildMapping({\n cwd,\n stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): Dictionary<IUsage> {\n const mapping = buildEmptyMapping(stepDefinitions)\n _.each(eventDataCollector.getTestCaseAttempts(), (testCaseAttempt) => {\n const pickleStepMap = getPickleStepMap(testCaseAttempt.pickle)\n const gherkinStepMap = getGherkinStepMap(testCaseAttempt.gherkinDocument)\n testCaseAttempt.testCase.testSteps.forEach((testStep) => {\n if (\n testStep.pickleStepId !== '' &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinitionId = testStep.stepDefinitionIds[0]\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n const gherkinStep = gherkinStepMap[pickleStep.astNodeIds[0]]\n const match: IUsageMatch = {\n line: gherkinStep.location.line,\n text: pickleStep.text,\n uri: path.relative(cwd, testCaseAttempt.pickle.uri),\n }\n const { duration, status } = testCaseAttempt.stepResults[testStep.id]\n if (\n ![\n messages.TestStepFinished.TestStepResult.Status.AMBIGUOUS,\n messages.TestStepFinished.TestStepResult.Status.SKIPPED,\n messages.TestStepFinished.TestStepResult.Status.UNDEFINED,\n ].includes(status) &&\n doesHaveValue(duration)\n ) {\n match.duration = duration\n }\n if (doesHaveValue(mapping[stepDefinitionId])) {\n mapping[stepDefinitionId].matches.push(match)\n }\n }\n })\n })\n return mapping\n}\n\nfunction invertDuration(duration: messages.IDuration): number {\n if (doesHaveValue(duration)) {\n return -1 * durationToMilliseconds(duration)\n }\n return 1\n}\n\nfunction buildResult(mapping: Dictionary<IUsage>): IUsage[] {\n return _.chain(mapping)\n .map(({ matches, ...rest }: IUsage) => {\n const sortedMatches = _.sortBy(matches, [\n (match: IUsageMatch) => invertDuration(match.duration),\n 'text',\n ])\n const result = { matches: sortedMatches, ...rest }\n const durations: messages.IDuration[] = _.chain(matches)\n .map((m: IUsageMatch) => m.duration)\n .compact()\n .value()\n if (durations.length > 0) {\n result.meanDuration = millisecondsToDuration(\n _.meanBy(durations, (d: messages.IDuration) =>\n durationToMilliseconds(d)\n )\n )\n }\n return result\n })\n .sortBy((usage: IUsage) => invertDuration(usage.meanDuration))\n .value()\n}\n\nexport function getUsage({\n cwd,\n stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): IUsage[] {\n const mapping = buildMapping({ cwd, stepDefinitions, eventDataCollector })\n return buildResult(mapping)\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/formatter/helpers/usage_helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,oDAAmD;AACnD,wEAA8D;AAC9D,6DAA8C;AAE9C,0DAAsD;AA0BtD,SAAS,iBAAiB,CACxB,eAAiC;IAEjC,MAAM,OAAO,GAA2B,EAAE,CAAA;IAC1C,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;QACzC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG;YAC3B,IAAI,EAAE,cAAc,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC7C,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,MAAM;YACzC,WAAW,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI;YACvD,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,cAAc,CAAC,GAAG;SACxB,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,kBAAkB,GAA6C;IACnE,QAAQ,CAAC,oBAAoB,CAAC,SAAS;IACvC,QAAQ,CAAC,oBAAoB,CAAC,OAAO;IACrC,QAAQ,CAAC,oBAAoB,CAAC,SA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BAAsB,CAAC,CAAC,CAAC,CAClD,CACF,CAAA;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SAC7D,KAAK,EAAE,CAAA;AACZ,CAAC;AAED,SAAgB,QAAQ,CAAC,EACvB,GAAG,EACH,eAAe,EACf,kBAAkB,GACD;IACjB,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAA;IAC1E,OAAO,WAAW,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAPD,4BAOC","sourcesContent":["import _ from 'lodash'\nimport { getPickleStepMap } from '../pickle_parser'\nimport { getGherkinStepMap } from '../gherkin_document_parser'\nimport * as messages from '@cucumber/messages'\nimport StepDefinition from '../../../models/step_definition'\nimport { doesHaveValue } from '../../../value_checker'\nimport EventDataCollector from '../event_data_collector'\n\nexport interface IUsageMatch {\n duration?: messages.Duration\n line: number\n text: string\n uri: string\n}\n\nexport interface IUsage {\n code: string\n line: number\n matches: IUsageMatch[]\n meanDuration?: messages.Duration\n pattern: string\n patternType: string\n uri: string\n}\n\nexport interface IGetUsageRequest {\n cwd: string\n eventDataCollector: EventDataCollector\n stepDefinitions: StepDefinition[]\n}\n\nfunction buildEmptyMapping(\n stepDefinitions: StepDefinition[]\n): Record<string, IUsage> {\n const mapping: Record<string, IUsage> = {}\n stepDefinitions.forEach((stepDefinition) => {\n mapping[stepDefinition.id] = {\n code: stepDefinition.unwrappedCode.toString(),\n line: stepDefinition.line,\n pattern: stepDefinition.expression.source,\n patternType: stepDefinition.expression.constructor.name,\n matches: [],\n uri: stepDefinition.uri,\n }\n })\n return mapping\n}\n\nconst unexecutedStatuses: readonly messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.SKIPPED,\n messages.TestStepResultStatus.UNDEFINED,\n]\n\nfunction buildMapping({\n cwd,\n stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): Record<string, IUsage> {\n const mapping = buildEmptyMapping(stepDefinitions)\n _.each(eventDataCollector.getTestCaseAttempts(), (testCaseAttempt) => {\n const pickleStepMap = getPickleStepMap(testCaseAttempt.pickle)\n const gherkinStepMap = getGherkinStepMap(testCaseAttempt.gherkinDocument)\n testCaseAttempt.testCase.testSteps.forEach((testStep) => {\n if (\n doesHaveValue(testStep.pickleStepId) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinitionId = testStep.stepDefinitionIds[0]\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n const gherkinStep = gherkinStepMap[pickleStep.astNodeIds[0]]\n const match: IUsageMatch = {\n line: gherkinStep.location.line,\n text: pickleStep.text,\n uri: testCaseAttempt.pickle.uri,\n }\n const { duration, status } = testCaseAttempt.stepResults[testStep.id]\n if (!unexecutedStatuses.includes(status) && doesHaveValue(duration)) {\n match.duration = duration\n }\n if (doesHaveValue(mapping[stepDefinitionId])) {\n mapping[stepDefinitionId].matches.push(match)\n }\n }\n })\n })\n return mapping\n}\n\nfunction invertDuration(duration: messages.Duration): number {\n if (doesHaveValue(duration)) {\n return -1 * messages.TimeConversion.durationToMilliseconds(duration)\n }\n return 1\n}\n\nfunction buildResult(mapping: Record<string, IUsage>): IUsage[] {\n return _.chain(mapping)\n .map(({ matches, ...rest }: IUsage) => {\n const sortedMatches = _.sortBy(matches, [\n (match: IUsageMatch) => invertDuration(match.duration),\n 'text',\n ])\n const result = { matches: sortedMatches, ...rest }\n const durations: messages.Duration[] = _.chain(matches)\n .map((m: IUsageMatch) => m.duration)\n .compact()\n .value()\n if (durations.length > 0) {\n result.meanDuration = messages.TimeConversion.millisecondsToDuration(\n _.meanBy(durations, (d: messages.Duration) =>\n messages.TimeConversion.durationToMilliseconds(d)\n )\n )\n }\n return result\n })\n .sortBy((usage: IUsage) => invertDuration(usage.meanDuration))\n .value()\n}\n\nexport function getUsage({\n cwd,\n stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): IUsage[] {\n const mapping = buildMapping({ cwd, stepDefinitions, eventDataCollector })\n return buildResult(mapping)\n}\n"]}
@@ -13,7 +13,7 @@ class HtmlFormatter extends _1.default {
13
13
  constructor(options) {
14
14
  super(options);
15
15
  const cucumberHtmlStream = new html_formatter_1.default(resolve_pkg_1.default('@cucumber/html-formatter', { cwd: __dirname }) +
16
- '/dist/cucumber-react.css', resolve_pkg_1.default('@cucumber/html-formatter', { cwd: __dirname }) +
16
+ '/dist/main.css', resolve_pkg_1.default('@cucumber/html-formatter', { cwd: __dirname }) +
17
17
  '/dist/main.js');
18
18
  options.eventBroadcaster.on('envelope', (envelope) => {
19
19
  cucumberHtmlStream.write(envelope);
@@ -1 +1 @@
1
- {"version":3,"file":"html_formatter.js","sourceRoot":"","sources":["../../src/formatter/html_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAEhD,8DAAoC;AACpC,8EAAyD;AACzD,oDAAgD;AAChD,mCAAiC;AACjC,+BAAgC;AAEhC,MAAqB,aAAc,SAAQ,UAAS;IAGlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,MAAM,kBAAkB,GAAG,IAAI,wBAAkB,CAC/C,qBAAU,CAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,0BAA0B,EAC5B,qBAAU,CAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,eAAe,CAClB,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YAClC,IAAI,6BAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,kBAAkB,CAAC,GAAG,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;QACF,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;QACzD,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,iBAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,SAAS,CAAA;QACpB,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;CACF;AAzBD,gCAyBC","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport { messages } from '@cucumber/messages'\nimport resolvePkg from 'resolve-pkg'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { finished } from 'stream'\nimport { promisify } from 'util'\n\nexport default class HtmlFormatter extends Formatter {\n private readonly _finished: Promise<void>\n\n constructor(options: IFormatterOptions) {\n super(options)\n const cucumberHtmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/cucumber-react.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n cucumberHtmlStream.write(envelope)\n if (doesHaveValue(envelope.testRunFinished)) {\n cucumberHtmlStream.end()\n }\n })\n cucumberHtmlStream.on('data', (chunk) => this.log(chunk))\n this._finished = promisify(finished)(cucumberHtmlStream)\n }\n\n async finished(): Promise<void> {\n await this._finished\n await super.finished()\n }\n}\n"]}
1
+ {"version":3,"file":"html_formatter.js","sourceRoot":"","sources":["../../src/formatter/html_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAEhD,8DAAoC;AACpC,8EAAyD;AACzD,oDAAgD;AAChD,mCAAiC;AACjC,+BAAgC;AAEhC,MAAqB,aAAc,SAAQ,UAAS;IAGlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,MAAM,kBAAkB,GAAG,IAAI,wBAAkB,CAC/C,qBAAU,CAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,qBAAU,CAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,eAAe,CAClB,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YAClC,IAAI,6BAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,kBAAkB,CAAC,GAAG,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;QACF,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;QACzD,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,iBAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,SAAS,CAAA;QACpB,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;CACF;AAzBD,gCAyBC","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\nimport resolvePkg from 'resolve-pkg'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { finished } from 'stream'\nimport { promisify } from 'util'\n\nexport default class HtmlFormatter extends Formatter {\n private readonly _finished: Promise<void>\n\n constructor(options: IFormatterOptions) {\n super(options)\n const cucumberHtmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n cucumberHtmlStream.write(envelope)\n if (doesHaveValue(envelope.testRunFinished)) {\n cucumberHtmlStream.end()\n }\n })\n cucumberHtmlStream.on('data', (chunk) => this.log(chunk))\n this._finished = promisify(finished)(cucumberHtmlStream)\n }\n\n async finished(): Promise<void> {\n await this._finished\n await super.finished()\n }\n}\n"]}
@@ -86,7 +86,7 @@ class HttpStream extends stream_1.Transform {
86
86
  if (upload) {
87
87
  additionalHttpHeaders['Content-Length'] = fs_1.default.statSync(this.tempFilePath).size;
88
88
  }
89
- const allHeaders = { ...headers, ...additionalHttpHeaders };
89
+ const allHeaders = Object.assign(Object.assign({}, headers), additionalHttpHeaders);
90
90
  const req = httpx.request(url, {
91
91
  method,
92
92
  headers: allHeaders,
@@ -1 +1 @@
1
- {"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/formatter/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,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACzB,IAAI,6BAAa,CAAC,GAAG,CAAC;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAA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,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,YAAE,CAAC,QAAQ,CACnD,IAAI,CAAC,YAAY,CAClB,CAAC,IAAI,CAAA;SACP;QAED,MAAM,UAAU,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,qBAAqB,EAAE,CAAA;QAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;YAC7B,MAAM;YACN,OAAO,EAAE,UAAU;SACpB,CAAC,CAAA;QACF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QACjD,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YACjD,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrB,CAAC,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE;YACV,iBAAQ,CAAC,YAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5D,IAAI,6BAAa,CAAC,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/formatter/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,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACzB,IAAI,6BAAa,CAAC,GAAG,CAAC;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAA;gBAC5C,IA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C,gBAAgB,CAAC,GAAG,YAAE,CAAC,QAAQ,CACnD,IAAI,CAAC,YAAY,CAClB,CAAC,IAAI,CAAA;SACP;QAED,MAAM,UAAU,mCAAQ,OAAO,GAAK,qBAAqB,CAAE,CAAA;QAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;YAC7B,MAAM;YACN,OAAO,EAAE,UAAU;SACpB,CAAC,CAAA;QACF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QACjD,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YACjD,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrB,CAAC,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE;YACV,iBAAQ,CAAC,YAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5D,IAAI,6BAAa,CAAC,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,10 +1,5 @@
1
- import { Dictionary } from 'lodash';
2
1
  import Formatter, { IFormatterOptions } from './';
3
- import { messages } from '@cucumber/messages';
4
- import IFeature = messages.GherkinDocument.IFeature;
5
- import IPickle = messages.IPickle;
6
- import IScenario = messages.GherkinDocument.Feature.IScenario;
7
- import IRule = messages.GherkinDocument.Feature.FeatureChild.IRule;
2
+ import * as messages from '@cucumber/messages';
8
3
  export interface IJsonFeature {
9
4
  description: string;
10
5
  elements: IJsonScenario[];
@@ -40,44 +35,43 @@ export interface IJsonTag {
40
35
  line: number;
41
36
  }
42
37
  interface IBuildJsonFeatureOptions {
43
- feature: messages.GherkinDocument.IFeature;
38
+ feature: messages.Feature;
44
39
  elements: IJsonScenario[];
45
40
  uri: string;
46
41
  }
47
42
  interface IBuildJsonScenarioOptions {
48
- feature: messages.GherkinDocument.IFeature;
49
- gherkinScenarioMap: Dictionary<IScenario>;
50
- gherkinExampleRuleMap: Dictionary<IRule>;
51
- gherkinScenarioLocationMap: Dictionary<messages.ILocation>;
52
- pickle: messages.IPickle;
43
+ feature: messages.Feature;
44
+ gherkinScenarioMap: Record<string, messages.Scenario>;
45
+ gherkinExampleRuleMap: Record<string, messages.Rule>;
46
+ gherkinScenarioLocationMap: Record<string, messages.Location>;
47
+ pickle: messages.Pickle;
53
48
  steps: IJsonStep[];
54
49
  }
55
50
  interface IBuildJsonStepOptions {
56
51
  isBeforeHook: boolean;
57
- gherkinStepMap: Dictionary<messages.GherkinDocument.Feature.IStep>;
58
- pickleStepMap: Dictionary<messages.Pickle.IPickleStep>;
59
- testStep: messages.TestCase.ITestStep;
60
- testStepAttachments: messages.IAttachment[];
61
- testStepResult: messages.TestStepFinished.ITestStepResult;
52
+ gherkinStepMap: Record<string, messages.Step>;
53
+ pickleStepMap: Record<string, messages.PickleStep>;
54
+ testStep: messages.TestStep;
55
+ testStepAttachments: messages.Attachment[];
56
+ testStepResult: messages.TestStepResult;
62
57
  }
63
58
  export default class JsonFormatter extends Formatter {
64
59
  constructor(options: IFormatterOptions);
65
- convertNameToId(obj: IFeature | IPickle): string;
66
- formatDataTable(dataTable: messages.PickleStepArgument.IPickleTable): any;
67
- formatDocString(docString: messages.PickleStepArgument.IPickleDocString, gherkinStep: messages.GherkinDocument.Feature.IStep): any;
68
- formatStepArgument(stepArgument: messages.IPickleStepArgument, gherkinStep: messages.GherkinDocument.Feature.IStep): any;
60
+ convertNameToId(obj: messages.Feature | messages.Pickle): string;
61
+ formatDataTable(dataTable: messages.PickleTable): any;
62
+ formatDocString(docString: messages.PickleDocString, gherkinStep: messages.Step): any;
63
+ formatStepArgument(stepArgument: messages.PickleStepArgument, gherkinStep: messages.Step): any;
69
64
  onTestRunFinished(): void;
70
65
  getFeatureData({ feature, elements, uri, }: IBuildJsonFeatureOptions): IJsonFeature;
71
66
  getScenarioData({ feature, gherkinScenarioLocationMap, gherkinExampleRuleMap, gherkinScenarioMap, pickle, steps, }: IBuildJsonScenarioOptions): IJsonScenario;
72
67
  private formatScenarioId;
73
68
  getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }: IBuildJsonStepOptions): IJsonStep;
74
- getFeatureTags(feature: IFeature): IJsonTag[];
69
+ getFeatureTags(feature: messages.Feature): IJsonTag[];
75
70
  getScenarioTags({ feature, pickle, gherkinScenarioMap, }: {
76
- feature: IFeature;
77
- pickle: IPickle;
78
- gherkinScenarioMap: {
79
- [id: string]: IScenario;
80
- };
71
+ feature: messages.Feature;
72
+ pickle: messages.Pickle;
73
+ gherkinScenarioMap: Record<string, messages.Scenario>;
81
74
  }): IJsonTag[];
75
+ private getScenarioTag;
82
76
  }
83
77
  export {};
@@ -1,23 +1,39 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
23
  };
5
24
  Object.defineProperty(exports, "__esModule", { value: true });
6
25
  const lodash_1 = __importDefault(require("lodash"));
7
26
  const _1 = __importDefault(require("./"));
8
- const status_1 = __importDefault(require("../status"));
9
27
  const helpers_1 = require("./helpers");
10
- const time_1 = require("../time");
11
- const path_1 = __importDefault(require("path"));
28
+ const messages = __importStar(require("@cucumber/messages"));
12
29
  const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
13
30
  const value_checker_1 = require("../value_checker");
14
31
  const step_arguments_1 = require("../step_arguments");
15
32
  const { getGherkinStepMap, getGherkinScenarioMap } = helpers_1.GherkinDocumentParser;
16
- const { getScenarioDescription, getPickleStepMap, getStepKeyword, } = helpers_1.PickleParser;
33
+ const { getScenarioDescription, getPickleStepMap, getStepKeyword } = helpers_1.PickleParser;
17
34
  class JsonFormatter extends _1.default {
18
35
  constructor(options) {
19
36
  super(options);
20
- console.warn("The built-in JSON formatter is deprecated and will be removed in the next major release. Where you need a structured data representation of your test run, it's best to use the `message` formatter. For legacy tools that depend on the deprecated JSON format, a standalone formatter is available (see https://github.com/cucumber/cucumber/tree/master/json-formatter).");
21
37
  options.eventBroadcaster.on('envelope', (envelope) => {
22
38
  if (value_checker_1.doesHaveValue(envelope.testRunFinished)) {
23
39
  this.onTestRunFinished();
@@ -53,7 +69,7 @@ class JsonFormatter extends _1.default {
53
69
  const groupedTestCaseAttempts = {};
54
70
  lodash_1.default.each(this.eventDataCollector.getTestCaseAttempts(), (testCaseAttempt) => {
55
71
  if (!testCaseAttempt.worstTestStepResult.willBeRetried) {
56
- const uri = path_1.default.relative(this.cwd, testCaseAttempt.pickle.uri);
72
+ const uri = testCaseAttempt.pickle.uri;
57
73
  if (value_checker_1.doesNotHaveValue(groupedTestCaseAttempts[uri])) {
58
74
  groupedTestCaseAttempts[uri] = [];
59
75
  }
@@ -71,7 +87,7 @@ class JsonFormatter extends _1.default {
71
87
  const pickleStepMap = getPickleStepMap(pickle);
72
88
  let isBeforeHook = true;
73
89
  const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {
74
- isBeforeHook = isBeforeHook && testStep.pickleStepId === '';
90
+ isBeforeHook = isBeforeHook && !value_checker_1.doesHaveValue(testStep.pickleStepId);
75
91
  return this.getStepData({
76
92
  isBeforeHook,
77
93
  gherkinStepMap,
@@ -139,7 +155,7 @@ class JsonFormatter extends _1.default {
139
155
  }
140
156
  getStepData({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
141
157
  const data = {};
142
- if (testStep.pickleStepId !== '') {
158
+ if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
143
159
  const pickleStep = pickleStepMap[testStep.pickleStepId];
144
160
  data.arguments = this.formatStepArgument(pickleStep.argument, gherkinStepMap[pickleStep.astNodeIds[0]]);
145
161
  data.keyword = getStepKeyword({ pickleStep, gherkinStepMap });
@@ -150,16 +166,21 @@ class JsonFormatter extends _1.default {
150
166
  data.keyword = isBeforeHook ? 'Before' : 'After';
151
167
  data.hidden = true;
152
168
  }
153
- if (testStep.stepDefinitionIds.length === 1) {
169
+ if (value_checker_1.doesHaveValue(testStep.stepDefinitionIds) &&
170
+ testStep.stepDefinitionIds.length === 1) {
154
171
  const stepDefinition = this.supportCodeLibrary.stepDefinitions.find((s) => s.id === testStep.stepDefinitionIds[0]);
155
172
  data.match = { location: helpers_1.formatLocation(stepDefinition) };
156
173
  }
157
174
  const { message, status } = testStepResult;
158
- data.result = { status: status_1.default[status].toLowerCase() };
175
+ data.result = {
176
+ status: messages.TestStepResultStatus[status].toLowerCase(),
177
+ };
159
178
  if (value_checker_1.doesHaveValue(testStepResult.duration)) {
160
- data.result.duration = time_1.durationToNanoseconds(testStepResult.duration);
179
+ data.result.duration =
180
+ messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;
161
181
  }
162
- if (status === status_1.default.FAILED && value_checker_1.doesHaveValue(message)) {
182
+ if (status === messages.TestStepResultStatus.FAILED &&
183
+ value_checker_1.doesHaveValue(message)) {
163
184
  data.result.error_message = message;
164
185
  }
165
186
  if (lodash_1.default.size(testStepAttachments) > 0) {
@@ -177,17 +198,23 @@ class JsonFormatter extends _1.default {
177
198
  }));
178
199
  }
179
200
  getScenarioTags({ feature, pickle, gherkinScenarioMap, }) {
180
- return lodash_1.default.map(pickle.tags, (tagData) => {
181
- const featureSource = feature.tags.find((t) => t.id === tagData.astNodeId);
182
- const scenarioSource = gherkinScenarioMap[pickle.astNodeIds[0]].tags.find((t) => t.id === tagData.astNodeId);
183
- const line = value_checker_1.doesHaveValue(featureSource)
184
- ? featureSource.location.line
185
- : scenarioSource.location.line;
186
- return {
187
- name: tagData.name,
188
- line,
189
- };
190
- });
201
+ const scenario = gherkinScenarioMap[pickle.astNodeIds[0]];
202
+ return pickle.tags.map((tagData) => this.getScenarioTag(tagData, feature, scenario));
203
+ }
204
+ getScenarioTag(tagData, feature, scenario) {
205
+ var _a;
206
+ const byAstNodeId = (tag) => tag.id === tagData.astNodeId;
207
+ const flatten = (acc, val) => acc.concat(val);
208
+ const tag = feature.tags.find(byAstNodeId) ||
209
+ scenario.tags.find(byAstNodeId) ||
210
+ scenario.examples
211
+ .map((e) => e.tags)
212
+ .reduce(flatten, [])
213
+ .find(byAstNodeId);
214
+ return {
215
+ name: tagData.name,
216
+ line: (_a = tag === null || tag === void 0 ? void 0 : tag.location) === null || _a === void 0 ? void 0 : _a.line,
217
+ };
191
218
  }
192
219
  }
193
220
  exports.default = JsonFormatter;
@@ -1 +1 @@
1
- {"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsC;AACtC,0CAAiD;AACjD,uDAA8B;AAC9B,uCAA+E;AAC/E,kCAA+C;AAC/C,gDAAuB;AAEvB,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AAQrD,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+BAAqB,CAAA;AAE1E,MAAM,EACJ,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,GACf,GAAG,sBAAY,CAAA;AAoEhB,MAAqB,aAAc,SAAQ,UAAS;IAClD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,IAAI,CACV,6WAA6W,CAC9W,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,6BAAa,CAAC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cAAc,CAAC,QAAQ,CAAC,IAAI,CAAA;YAChC,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,IAAI;aACL,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAhPD,gCAgPC","sourcesContent":["import _, { Dictionary } from 'lodash'\nimport Formatter, { IFormatterOptions } from './'\nimport Status from '../status'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport { durationToNanoseconds } from '../time'\nimport path from 'path'\nimport { messages } from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\nimport ITag = messages.GherkinDocument.Feature.ITag\nimport IFeature = messages.GherkinDocument.IFeature\nimport IPickle = messages.IPickle\nimport IScenario = messages.GherkinDocument.Feature.IScenario\nimport IEnvelope = messages.IEnvelope\nimport IRule = messages.GherkinDocument.Feature.FeatureChild.IRule\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst {\n getScenarioDescription,\n getPickleStepMap,\n getStepKeyword,\n} = PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.GherkinDocument.IFeature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.GherkinDocument.IFeature\n gherkinScenarioMap: Dictionary<IScenario>\n gherkinExampleRuleMap: Dictionary<IRule>\n gherkinScenarioLocationMap: Dictionary<messages.ILocation>\n pickle: messages.IPickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Dictionary<messages.GherkinDocument.Feature.IStep>\n pickleStepMap: Dictionary<messages.Pickle.IPickleStep>\n testStep: messages.TestCase.ITestStep\n testStepAttachments: messages.IAttachment[]\n testStepResult: messages.TestStepFinished.ITestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n console.warn(\n \"The built-in JSON formatter is deprecated and will be removed in the next major release. Where you need a structured data representation of your test run, it's best to use the `message` formatter. For legacy tools that depend on the deprecated JSON format, a standalone formatter is available (see https://github.com/cucumber/cucumber/tree/master/json-formatter).\"\n )\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: IFeature | IPickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleStepArgument.IPickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({ cells: _.map(row.cells, 'value') })),\n }\n }\n\n formatDocString(\n docString: messages.PickleStepArgument.IPickleDocString,\n gherkinStep: messages.GherkinDocument.Feature.IStep\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.IPickleStepArgument,\n gherkinStep: messages.GherkinDocument.Feature.IStep\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n _.each(\n this.eventDataCollector.getTestCaseAttempts(),\n (testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.worstTestStepResult.willBeRetried) {\n const uri = path.relative(this.cwd, testCaseAttempt.pickle.uri)\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n }\n )\n const features = _.map(groupedTestCaseAttempts, (group, uri) => {\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(\n gherkinDocument\n )\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && testStep.pickleStepId === ''\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: IFeature\n pickle: IPickle\n gherkinExampleRuleMap: Dictionary<IRule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (testStep.pickleStepId !== '') {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (testStep.stepDefinitionIds.length === 1) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = { status: Status[status].toLowerCase() }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration = durationToNanoseconds(testStepResult.duration)\n }\n if (status === Status.FAILED && doesHaveValue(message)) {\n data.result.error_message = message\n }\n if (_.size(testStepAttachments) > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: IFeature): IJsonTag[] {\n return _.map(feature.tags, (tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: IFeature\n pickle: IPickle\n gherkinScenarioMap: { [id: string]: IScenario }\n }): IJsonTag[] {\n return _.map(pickle.tags, (tagData) => {\n const featureSource = feature.tags.find(\n (t: ITag) => t.id === tagData.astNodeId\n )\n const scenarioSource = gherkinScenarioMap[pickle.astNodeIds[0]].tags.find(\n (t: ITag) => t.id === tagData.astNodeId\n )\n const line = doesHaveValue(featureSource)\n ? featureSource.location.line\n : scenarioSource.location.line\n return {\n name: tagData.name,\n line,\n }\n })\n }\n}\n"]}
1
+ {"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsB;AACtB,0CAAiD;AACjD,uCAA+E;AAC/E,6DAA8C;AAC9C,+EAG0C;AAE1C,oDAAkE;AAClE,sDAAqD;AAErD,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,+BAAqB,CAAA;AAE1E,MAAM,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAChE,sBAAY,CAAA;AAoEd,MAAqB,aAAc,SAAQ,UAAS;IAClD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,6BAAa,CAAC,QAAQ,CAAC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,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAEpC,MAAM,GAAG,GACP,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC/B,QAAQ,CAAC,QAAQ;iBACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;iBACnB,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtB,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,0CAAE,IAAI;SAC1B,CAAA;IACH,CAAC;CACF;AAxQD,gCAwQC","sourcesContent":["import _ from 'lodash'\nimport Formatter, { IFormatterOptions } from './'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport * as messages from '@cucumber/messages'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\n\nconst { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser\n\nconst { getScenarioDescription, getPickleStepMap, getStepKeyword } =\n PickleParser\n\nexport interface IJsonFeature {\n description: string\n elements: IJsonScenario[]\n id: string\n keyword: string\n line: number\n name: string\n tags: IJsonTag[]\n uri: string\n}\n\nexport interface IJsonScenario {\n description: string\n id: string\n keyword: string\n line: number\n name: string\n steps: IJsonStep[]\n tags: IJsonTag[]\n type: string\n}\n\nexport interface IJsonStep {\n arguments?: any // TODO\n embeddings?: any // TODO\n hidden?: boolean\n keyword?: string // TODO, not optional\n line?: number\n match?: any // TODO\n name?: string\n result?: any // TODO\n}\n\nexport interface IJsonTag {\n name: string\n line: number\n}\n\ninterface IBuildJsonFeatureOptions {\n feature: messages.Feature\n elements: IJsonScenario[]\n uri: string\n}\n\ninterface IBuildJsonScenarioOptions {\n feature: messages.Feature\n gherkinScenarioMap: Record<string, messages.Scenario>\n gherkinExampleRuleMap: Record<string, messages.Rule>\n gherkinScenarioLocationMap: Record<string, messages.Location>\n pickle: messages.Pickle\n steps: IJsonStep[]\n}\n\ninterface IBuildJsonStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\ninterface UriToTestCaseAttemptsMap {\n [uri: string]: ITestCaseAttempt[]\n}\n\nexport default class JsonFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n convertNameToId(obj: messages.Feature | messages.Pickle): string {\n return obj.name.replace(/ /g, '-').toLowerCase()\n }\n\n formatDataTable(dataTable: messages.PickleTable): any {\n return {\n rows: dataTable.rows.map((row) => ({ cells: _.map(row.cells, 'value') })),\n }\n }\n\n formatDocString(\n docString: messages.PickleDocString,\n gherkinStep: messages.Step\n ): any {\n return {\n content: docString.content,\n line: gherkinStep.docString.location.line,\n }\n }\n\n formatStepArgument(\n stepArgument: messages.PickleStepArgument,\n gherkinStep: messages.Step\n ): any {\n if (doesNotHaveValue(stepArgument)) {\n return []\n }\n return [\n parseStepArgument<any>(stepArgument, {\n dataTable: (dataTable) => this.formatDataTable(dataTable),\n docString: (docString) => this.formatDocString(docString, gherkinStep),\n }),\n ]\n }\n\n onTestRunFinished(): void {\n const groupedTestCaseAttempts: UriToTestCaseAttemptsMap = {}\n _.each(\n this.eventDataCollector.getTestCaseAttempts(),\n (testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.worstTestStepResult.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n }\n )\n const features = _.map(groupedTestCaseAttempts, (group, uri) => {\n const { gherkinDocument } = group[0]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {\n const { pickle } = testCaseAttempt\n const pickleStepMap = getPickleStepMap(pickle)\n let isBeforeHook = true\n const steps = testCaseAttempt.testCase.testSteps.map((testStep) => {\n isBeforeHook = isBeforeHook && !doesHaveValue(testStep.pickleStepId)\n return this.getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n return this.getScenarioData({\n feature: gherkinDocument.feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n })\n })\n return this.getFeatureData({\n feature: gherkinDocument.feature,\n elements,\n uri,\n })\n })\n this.log(JSON.stringify(features, null, 2))\n }\n\n getFeatureData({\n feature,\n elements,\n uri,\n }: IBuildJsonFeatureOptions): IJsonFeature {\n return {\n description: feature.description,\n elements,\n id: this.convertNameToId(feature),\n line: feature.location.line,\n keyword: feature.keyword,\n name: feature.name,\n tags: this.getFeatureTags(feature),\n uri,\n }\n }\n\n getScenarioData({\n feature,\n gherkinScenarioLocationMap,\n gherkinExampleRuleMap,\n gherkinScenarioMap,\n pickle,\n steps,\n }: IBuildJsonScenarioOptions): IJsonScenario {\n const description = getScenarioDescription({\n pickle,\n gherkinScenarioMap,\n })\n return {\n description,\n id: this.formatScenarioId({ feature, pickle, gherkinExampleRuleMap }),\n keyword: gherkinScenarioMap[pickle.astNodeIds[0]].keyword,\n line: gherkinScenarioLocationMap[pickle.astNodeIds[0]].line,\n name: pickle.name,\n steps,\n tags: this.getScenarioTags({ feature, pickle, gherkinScenarioMap }),\n type: 'scenario',\n }\n }\n\n private formatScenarioId({\n feature,\n pickle,\n gherkinExampleRuleMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinExampleRuleMap: Record<string, messages.Rule>\n }): string {\n let parts: any[]\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n if (doesHaveValue(rule)) {\n parts = [feature, rule, pickle]\n } else {\n parts = [feature, pickle]\n }\n return parts.map((part) => this.convertNameToId(part)).join(';')\n }\n\n getStepData({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJsonStepOptions): IJsonStep {\n const data: IJsonStep = {}\n if (doesHaveValue(testStep.pickleStepId)) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.arguments = this.formatStepArgument(\n pickleStep.argument,\n gherkinStepMap[pickleStep.astNodeIds[0]]\n )\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = this.supportCodeLibrary.stepDefinitions.find(\n (s) => s.id === testStep.stepDefinitionIds[0]\n )\n data.match = { location: formatLocation(stepDefinition) }\n }\n const { message, status } = testStepResult\n data.result = {\n status: messages.TestStepResultStatus[status].toLowerCase(),\n }\n if (doesHaveValue(testStepResult.duration)) {\n data.result.duration =\n messages.TimeConversion.durationToMilliseconds(\n testStepResult.duration\n ) * 1000000\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (_.size(testStepAttachments) > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data: attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return _.map(feature.tags, (tagData) => ({\n name: tagData.name,\n line: tagData.location.line,\n }))\n }\n\n getScenarioTags({\n feature,\n pickle,\n gherkinScenarioMap,\n }: {\n feature: messages.Feature\n pickle: messages.Pickle\n gherkinScenarioMap: Record<string, messages.Scenario>\n }): IJsonTag[] {\n const scenario = gherkinScenarioMap[pickle.astNodeIds[0]]\n\n return pickle.tags.map(\n (tagData: messages.PickleTag): IJsonTag =>\n this.getScenarioTag(tagData, feature, scenario)\n )\n }\n\n private getScenarioTag(\n tagData: messages.PickleTag,\n feature: messages.Feature,\n scenario: messages.Scenario\n ): IJsonTag {\n const byAstNodeId = (tag: messages.Tag): Boolean =>\n tag.id === tagData.astNodeId\n const flatten = (\n acc: messages.Tag[],\n val: messages.Tag[]\n ): messages.Tag[] => acc.concat(val)\n\n const tag =\n feature.tags.find(byAstNodeId) ||\n scenario.tags.find(byAstNodeId) ||\n scenario.examples\n .map((e) => e.tags)\n .reduce(flatten, [])\n .find(byAstNodeId)\n\n return {\n name: tagData.name,\n line: tag?.location?.line,\n }\n }\n}\n"]}
@@ -7,7 +7,7 @@ const _1 = __importDefault(require("."));
7
7
  class MessageFormatter extends _1.default {
8
8
  constructor(options) {
9
9
  super(options);
10
- options.eventBroadcaster.on('envelope', (envelope) => this.log(JSON.stringify(envelope.toJSON()) + '\n'));
10
+ options.eventBroadcaster.on('envelope', (envelope) => this.log(JSON.stringify(envelope) + '\n'));
11
11
  }
12
12
  }
13
13
  exports.default = MessageFormatter;
@@ -1 +1 @@
1
- {"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;IACrD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CACnD,CAAA;IACH,CAAC;CACF;AAPD,mCAOC","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport { messages } from '@cucumber/messages'\n\nexport default class MessageFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope.toJSON()) + '\\n')\n )\n }\n}\n"]}
1
+ {"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAGhD,MAAqB,gBAAiB,SAAQ,UAAS;IACrD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAC1C,CAAA;IACH,CAAC;CACF;AAPD,mCAOC","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\n\nexport default class MessageFormatter extends Formatter {\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope) + '\\n')\n )\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import Formatter, { IFormatterOptions } from './';
2
2
  import ProgressBar from 'progress';
3
- import { messages } from '@cucumber/messages';
3
+ import * as messages from '@cucumber/messages';
4
4
  export default class ProgressBarFormatter extends Formatter {
5
5
  private numberOfSteps;
6
6
  private testRunStarted;
@@ -9,9 +9,9 @@ export default class ProgressBarFormatter extends Formatter {
9
9
  constructor(options: IFormatterOptions);
10
10
  incrementStepCount(pickleId: string): void;
11
11
  initializeProgressBar(): void;
12
- logProgress({ testStepId, testCaseStartedId, }: messages.ITestStepFinished): void;
13
- logUndefinedParametertype(parameterType: messages.IUndefinedParameterType): void;
14
- logErrorIfNeeded(testCaseFinished: messages.ITestCaseFinished): void;
15
- logSummary(testRunFinished: messages.ITestRunFinished): void;
16
- parseEnvelope(envelope: messages.IEnvelope): void;
12
+ logProgress({ testStepId, testCaseStartedId, }: messages.TestStepFinished): void;
13
+ logUndefinedParametertype(parameterType: messages.UndefinedParameterType): void;
14
+ logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void;
15
+ logSummary(testRunFinished: messages.TestRunFinished): void;
16
+ parseEnvelope(envelope: messages.Envelope): void;
17
17
  }
@@ -36,7 +36,7 @@ class ProgressBarFormatter extends _1.default {
36
36
  logProgress({ testStepId, testCaseStartedId, }) {
37
37
  const { testCase } = this.eventDataCollector.getTestCaseAttempt(testCaseStartedId);
38
38
  const testStep = testCase.testSteps.find((s) => s.id === testStepId);
39
- if (testStep.pickleStepId !== '') {
39
+ if (value_checker_1.doesHaveValue(testStep.pickleStepId)) {
40
40
  this.progressBar.tick();
41
41
  }
42
42
  }
@@ -74,8 +74,8 @@ class ProgressBarFormatter extends _1.default {
74
74
  if (value_checker_1.doesHaveValue(envelope.undefinedParameterType)) {
75
75
  this.logUndefinedParametertype(envelope.undefinedParameterType);
76
76
  }
77
- else if (value_checker_1.doesHaveValue(envelope.pickle)) {
78
- this.incrementStepCount(envelope.pickle.id);
77
+ else if (value_checker_1.doesHaveValue(envelope.testCase)) {
78
+ this.incrementStepCount(envelope.testCase.pickleId);
79
79
  }
80
80
  else if (value_checker_1.doesHaveValue(envelope.testStepStarted)) {
81
81
  this.initializeProgressBar();