@cucumber/cucumber 9.6.0 → 10.0.1
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.
- package/README.md +2 -2
- package/lib/api/console_logger.d.ts +1 -1
- package/lib/api/console_logger.js +5 -2
- package/lib/api/console_logger.js.map +1 -1
- package/lib/api/convert_configuration.d.ts +1 -1
- package/lib/api/convert_configuration.js +2 -2
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/formatters.d.ts +2 -2
- package/lib/api/formatters.js +6 -6
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/gherkin.d.ts +1 -1
- package/lib/api/gherkin.js +1 -1
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/load_configuration.js +1 -2
- package/lib/api/load_configuration.js.map +1 -1
- package/lib/api/load_sources.js +1 -1
- package/lib/api/load_sources.js.map +1 -1
- package/lib/api/load_support.d.ts +1 -1
- package/lib/api/load_support.js.map +1 -1
- package/lib/api/paths.d.ts +1 -1
- package/lib/api/paths.js +18 -17
- package/lib/api/paths.js.map +1 -1
- package/lib/api/plugins.d.ts +1 -1
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/run_cucumber.js +2 -2
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/runtime.d.ts +3 -3
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/support.js +2 -4
- package/lib/api/support.js.map +1 -1
- package/lib/api/test_helpers.js +8 -8
- package/lib/api/test_helpers.js.map +1 -1
- package/lib/api/types.d.ts +1 -1
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +4 -4
- package/lib/cli/helpers.js +5 -5
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +6 -1
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/run.js +1 -1
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.js +4 -4
- package/lib/cli/validate_node_engine_version.js.map +1 -1
- package/lib/configuration/from_file.d.ts +1 -1
- package/lib/configuration/from_file.js +41 -21
- package/lib/configuration/from_file.js.map +1 -1
- package/lib/configuration/locate_file.js +2 -2
- package/lib/configuration/locate_file.js.map +1 -1
- package/lib/configuration/merge_configurations.js.map +1 -1
- package/lib/configuration/validate_configuration.d.ts +1 -1
- package/lib/configuration/validate_configuration.js +3 -0
- package/lib/configuration/validate_configuration.js.map +1 -1
- package/lib/filter_stack_trace.js +4 -4
- package/lib/filter_stack_trace.js.map +1 -1
- package/lib/formatter/builder.d.ts +5 -5
- package/lib/formatter/builder.js +11 -24
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +1 -1
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +1 -1
- package/lib/formatter/helpers/event_data_collector.js +5 -5
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +2 -2
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +1 -1
- package/lib/formatter/helpers/summary_helpers.js +1 -1
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js +3 -3
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.js +1 -1
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +6 -5
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/index.d.ts +3 -3
- package/lib/formatter/index.js +10 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -1
- package/lib/formatter/json_formatter.js +10 -8
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/junit_formatter.js +11 -12
- package/lib/formatter/junit_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.js +1 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +1 -1
- package/lib/formatter/progress_bar_formatter.js +8 -4
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +1 -1
- package/lib/formatter/progress_formatter.js +3 -3
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.js +5 -4
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +4 -4
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +2 -2
- package/lib/formatter/step_definition_snippet_builder/index.js +3 -1
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +1 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +1 -1
- package/lib/formatter/summary_formatter.js +4 -4
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +4 -4
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js +2 -2
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.js +1 -0
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +1 -1
- package/lib/models/definition.js +6 -0
- package/lib/models/definition.js.map +1 -1
- package/lib/models/step_definition.d.ts +1 -1
- package/lib/models/step_definition.js +5 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +1 -1
- package/lib/models/test_case_hook_definition.js +3 -0
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +1 -1
- package/lib/models/test_step_hook_definition.js +2 -0
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.js +11 -5
- package/lib/pickle_filter.js.map +1 -1
- package/lib/plugin/plugin_manager.d.ts +1 -1
- package/lib/plugin/plugin_manager.js +3 -2
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +1 -1
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/http_stream.d.ts +2 -2
- package/lib/publish/http_stream.js +14 -9
- package/lib/publish/http_stream.js.map +1 -1
- package/lib/publish/publish_plugin.js +3 -3
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +1 -1
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.d.ts +1 -1
- package/lib/runtime/attachment_manager/index.js +1 -0
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/format_error.js +1 -1
- package/lib/runtime/format_error.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -1
- package/lib/runtime/helpers.js +2 -2
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +1 -1
- package/lib/runtime/index.js +9 -0
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +4 -4
- package/lib/runtime/parallel/coordinator.js +24 -5
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -1
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.js +14 -6
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.js +1 -1
- package/lib/runtime/run_test_run_hooks.js.map +1 -1
- package/lib/runtime/step_runner.js +2 -2
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +2 -0
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +1 -1
- package/lib/runtime/test_case_runner.js +19 -3
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/step_arguments.js +2 -2
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +2 -2
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +1 -1
- package/lib/support_code_library_builder/index.js +24 -8
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js +1 -4
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -1
- package/lib/support_code_library_builder/world.js +3 -0
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +1 -1
- package/lib/time.js +2 -2
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +3 -3
- package/lib/user_code_runner.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +16 -14
- package/lib/formatter/fixtures/typescript.d.ts +0 -2
- package/lib/formatter/fixtures/typescript.js +0 -6
- package/lib/formatter/fixtures/typescript.js.map +0 -1
- package/lib/importer.js +0 -13
package/lib/formatter/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
3
6
|
import { IColorFns } from './get_color_fns';
|
|
4
7
|
import { EventDataCollector } from './helpers';
|
|
5
8
|
import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
|
|
6
|
-
import { Writable } from 'stream';
|
|
7
|
-
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
-
import { EventEmitter } from 'events';
|
|
9
9
|
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
|
|
10
10
|
export interface FormatRerunOptions {
|
|
11
11
|
separator?: string;
|
package/lib/formatter/index.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const value_checker_1 = require("../value_checker");
|
|
4
4
|
class Formatter {
|
|
5
|
+
colorFns;
|
|
6
|
+
cwd;
|
|
7
|
+
eventDataCollector;
|
|
8
|
+
log;
|
|
9
|
+
snippetBuilder;
|
|
10
|
+
stream;
|
|
11
|
+
supportCodeLibrary;
|
|
12
|
+
printAttachments;
|
|
13
|
+
cleanup;
|
|
14
|
+
static documentation;
|
|
5
15
|
constructor(options) {
|
|
6
16
|
this.colorFns = options.colorFns;
|
|
7
17
|
this.cwd = options.cwd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAGA,oDAAiD;AAyCjD,MAAqB,SAAS;IAClB,QAAQ,CAAW;IACnB,GAAG,CAAQ;IACX,kBAAkB,CAAoB;IACtC,GAAG,CAAiB;IACpB,cAAc,CAA8B;IAC5C,MAAM,CAAU;IAChB,kBAAkB,CAAqB;IACvC,gBAAgB,CAAS;IAClB,OAAO,CAAqB;IAC7C,MAAM,CAAU,aAAa,CAAQ;IAErC,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { Writable } from 'node:stream'\nimport { EventEmitter } from 'node:events'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { valueOrDefault } from '../value_checker'\nimport { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport interface IPublishConfig {\n url: string\n token: string\n}\n\nexport type IFormatterStream = Writable\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: Writable\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: Writable\n protected supportCodeLibrary: ISupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
|
|
@@ -26,16 +26,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const _1 = __importDefault(require("./"));
|
|
30
|
-
const helpers_1 = require("./helpers");
|
|
31
29
|
const messages = __importStar(require("@cucumber/messages"));
|
|
32
|
-
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
33
30
|
const value_checker_1 = require("../value_checker");
|
|
34
31
|
const step_arguments_1 = require("../step_arguments");
|
|
32
|
+
const helpers_1 = require("./helpers");
|
|
33
|
+
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
35
34
|
const duration_helpers_1 = require("./helpers/duration_helpers");
|
|
35
|
+
const _1 = __importDefault(require("./"));
|
|
36
36
|
const { getGherkinStepMap, getGherkinScenarioMap } = helpers_1.GherkinDocumentParser;
|
|
37
37
|
const { getScenarioDescription, getPickleStepMap, getStepKeyword } = helpers_1.PickleParser;
|
|
38
38
|
class JsonFormatter extends _1.default {
|
|
39
|
+
static documentation = 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/json-formatter).';
|
|
39
40
|
constructor(options) {
|
|
40
41
|
super(options);
|
|
41
42
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
@@ -191,9 +192,12 @@ class JsonFormatter extends _1.default {
|
|
|
191
192
|
(0, value_checker_1.doesHaveValue)(message)) {
|
|
192
193
|
data.result.error_message = message;
|
|
193
194
|
}
|
|
194
|
-
if (
|
|
195
|
+
if (testStepAttachments?.length > 0) {
|
|
195
196
|
data.embeddings = testStepAttachments.map((attachment) => ({
|
|
196
|
-
data: attachment.
|
|
197
|
+
data: attachment.contentEncoding ===
|
|
198
|
+
messages.AttachmentContentEncoding.IDENTITY
|
|
199
|
+
? Buffer.from(attachment.body).toString('base64')
|
|
200
|
+
: attachment.body,
|
|
197
201
|
mime_type: attachment.mediaType,
|
|
198
202
|
}));
|
|
199
203
|
}
|
|
@@ -210,7 +214,6 @@ class JsonFormatter extends _1.default {
|
|
|
210
214
|
return pickle.tags.map((tagData) => this.getScenarioTag(tagData, feature, scenario));
|
|
211
215
|
}
|
|
212
216
|
getScenarioTag(tagData, feature, scenario) {
|
|
213
|
-
var _a;
|
|
214
217
|
const byAstNodeId = (tag) => tag.id === tagData.astNodeId;
|
|
215
218
|
const flatten = (acc, val) => acc.concat(val);
|
|
216
219
|
const tag = feature.tags.find(byAstNodeId) ||
|
|
@@ -221,10 +224,9 @@ class JsonFormatter extends _1.default {
|
|
|
221
224
|
.find(byAstNodeId);
|
|
222
225
|
return {
|
|
223
226
|
name: tagData.name,
|
|
224
|
-
line:
|
|
227
|
+
line: tag?.location?.line,
|
|
225
228
|
};
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
exports.default = JsonFormatter;
|
|
229
|
-
JsonFormatter.documentation = 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/json-formatter).';
|
|
230
232
|
//# sourceMappingURL=json_formatter.js.map
|
|
@@ -1 +1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AC;;AA3QH,gCA4QC;AA3QwB,2BAAa,GAClC,kMAAkM,CAAA","sourcesContent":["import 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'\nimport { durationToNanoseconds } from './helpers/duration_helpers'\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 public static readonly documentation: string =\n 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/json-formatter).'\n\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) => ({\n cells: row.cells.map((x) => x.value),\n })),\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 this.eventDataCollector\n .getTestCaseAttempts()\n .forEach((testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n })\n const features = Object.keys(groupedTestCaseAttempts).map((uri) => {\n const group = groupedTestCaseAttempts[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[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].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 = durationToNanoseconds(testStepResult.duration)\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (testStepAttachments?.length > 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 feature.tags.map((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"]}
|
|
1
|
+
{"version":3,"file":"json_formatter.js","sourceRoot":"","sources":["../../src/formatter/json_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,oDAAkE;AAClE,sDAAqD;AACrD,uCAA+E;AAC/E,+EAG0C;AAE1C,iEAAkE;AAClE,0CAAiD;AAEjD,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;IAC3C,MAAM,CAAU,aAAa,GAClC,kMAAkM,CAAA;IAEpM,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,C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B,EAC3B,OAAyB,EACzB,QAA2B;QAE3B,MAAM,WAAW,GAAG,CAAC,GAAiB,EAAW,EAAE,CACjD,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,SAAS,CAAA;QAC9B,MAAM,OAAO,GAAG,CACd,GAAmB,EACnB,GAAmB,EACH,EAAE,CAAC,GAAG,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,GAAG,EAAE,QAAQ,EAAE,IAAI;SAC1B,CAAA;IACH,CAAC;;AA/QH,gCAgRC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { parseStepArgument } from '../step_arguments'\nimport { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'\nimport {\n getGherkinExampleRuleMap,\n getGherkinScenarioLocationMap,\n} from './helpers/gherkin_document_parser'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { durationToNanoseconds } from './helpers/duration_helpers'\nimport Formatter, { IFormatterOptions } from './'\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 public static readonly documentation: string =\n 'Prints the feature as JSON. The JSON format is in maintenance mode. Please consider using the message formatter with the standalone json-formatter (https://github.com/cucumber/json-formatter).'\n\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) => ({\n cells: row.cells.map((x) => x.value),\n })),\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 this.eventDataCollector\n .getTestCaseAttempts()\n .forEach((testCaseAttempt: ITestCaseAttempt) => {\n if (!testCaseAttempt.willBeRetried) {\n const uri = testCaseAttempt.pickle.uri\n if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {\n groupedTestCaseAttempts[uri] = []\n }\n groupedTestCaseAttempts[uri].push(testCaseAttempt)\n }\n })\n const features = Object.keys(groupedTestCaseAttempts).map((uri) => {\n const group = groupedTestCaseAttempts[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[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].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 = durationToNanoseconds(testStepResult.duration)\n }\n if (\n status === messages.TestStepResultStatus.FAILED &&\n doesHaveValue(message)\n ) {\n data.result.error_message = message\n }\n if (testStepAttachments?.length > 0) {\n data.embeddings = testStepAttachments.map((attachment) => ({\n data:\n attachment.contentEncoding ===\n messages.AttachmentContentEncoding.IDENTITY\n ? Buffer.from(attachment.body).toString('base64')\n : attachment.body,\n mime_type: attachment.mediaType,\n }))\n }\n return data\n }\n\n getFeatureTags(feature: messages.Feature): IJsonTag[] {\n return feature.tags.map((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"]}
|
|
@@ -4,18 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const xmlbuilder_1 = __importDefault(require("xmlbuilder"));
|
|
7
|
-
const _1 = __importDefault(require("./"));
|
|
8
7
|
const messages_1 = require("@cucumber/messages");
|
|
9
8
|
const value_checker_1 = require("../value_checker");
|
|
9
|
+
const value_checker_2 = require("../value_checker");
|
|
10
10
|
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
11
11
|
const pickle_parser_1 = require("./helpers/pickle_parser");
|
|
12
|
-
const
|
|
12
|
+
const _1 = __importDefault(require("./"));
|
|
13
13
|
class JunitFormatter extends _1.default {
|
|
14
|
+
names = {};
|
|
15
|
+
suiteName;
|
|
16
|
+
static documentation = 'Outputs JUnit report';
|
|
14
17
|
constructor(options) {
|
|
15
|
-
var _a;
|
|
16
18
|
super(options);
|
|
17
|
-
this.
|
|
18
|
-
this.suiteName = (0, value_checker_2.valueOrDefault)((_a = options.parsedArgvOptions.junit) === null || _a === void 0 ? void 0 : _a.suiteName, 'cucumber-js');
|
|
19
|
+
this.suiteName = (0, value_checker_2.valueOrDefault)(options.parsedArgvOptions.junit?.suiteName, 'cucumber-js');
|
|
19
20
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
20
21
|
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
21
22
|
this.onTestRunFinished();
|
|
@@ -65,8 +66,8 @@ class JunitFormatter extends _1.default {
|
|
|
65
66
|
status,
|
|
66
67
|
failure: message || exception
|
|
67
68
|
? {
|
|
68
|
-
type: exception
|
|
69
|
-
message: exception
|
|
69
|
+
type: exception?.type,
|
|
70
|
+
message: exception?.message,
|
|
70
71
|
detail: message,
|
|
71
72
|
}
|
|
72
73
|
: undefined,
|
|
@@ -153,7 +154,6 @@ class JunitFormatter extends _1.default {
|
|
|
153
154
|
.att('time', testSuite.time)
|
|
154
155
|
.att('tests', testSuite.tests.length);
|
|
155
156
|
testSuite.tests.forEach((test) => {
|
|
156
|
-
var _a, _b, _c;
|
|
157
157
|
const xmlTestCase = xmlReport.ele('testcase', {
|
|
158
158
|
classname: test.classname,
|
|
159
159
|
name: test.name,
|
|
@@ -164,10 +164,10 @@ class JunitFormatter extends _1.default {
|
|
|
164
164
|
}
|
|
165
165
|
else if (test.result.status !== messages_1.TestStepResultStatus.PASSED) {
|
|
166
166
|
const xmlFailure = xmlTestCase.ele('failure', {
|
|
167
|
-
type:
|
|
168
|
-
message:
|
|
167
|
+
type: test.result.failure?.type,
|
|
168
|
+
message: test.result.failure?.message,
|
|
169
169
|
});
|
|
170
|
-
if (
|
|
170
|
+
if (test.result?.failure) {
|
|
171
171
|
xmlFailure.cdata(test.result.failure.detail);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -177,5 +177,4 @@ class JunitFormatter extends _1.default {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
exports.default = JunitFormatter;
|
|
180
|
-
JunitFormatter.documentation = 'Outputs JUnit report';
|
|
181
180
|
//# sourceMappingURL=junit_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"junit_formatter.js","sourceRoot":"","sources":["../../src/formatter/junit_formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AACnC,0CAAiD;AAEjD,iDAS2B;AAE3B,oDAAgD;AAChD,+EAG0C;AAC1C,2DAA0E;AAC1E,oDAAiD;AAiDjD,MAAqB,cAAe,SAAQ,UAAS;IAKnD,YAAY,OAA0B;;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QALC,UAAK,GAA6B,EAAE,CAAA;QAMnD,IAAI,CAAC,SAAS,GAAG,IAAA,8BAAc,EAC7B,MAAA,OAAO,CAAC,iBAAiB,CAAC,KAAK,0CAAE,SAAS,EAC1C,aAAa,CACd,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAA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C5D,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;;AA5NH,iCA6NC;AA1NwB,4BAAa,GAAW,sBAAsB,CAAA","sourcesContent":["import xmlbuilder from 'xmlbuilder'\nimport Formatter, { IFormatterOptions } from './'\nimport * as messages from '@cucumber/messages'\nimport {\n Attachment,\n Duration,\n Feature,\n getWorstTestStepResult,\n Pickle,\n Rule,\n TestStepResult,\n TestStepResultStatus,\n} from '@cucumber/messages'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue } from '../value_checker'\nimport {\n getGherkinExampleRuleMap,\n getGherkinStepMap,\n} from './helpers/gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './helpers/pickle_parser'\nimport { valueOrDefault } from '../value_checker'\n\ninterface IJUnitTestSuite {\n name: string\n failures: number\n skipped: number\n time: number\n tests: IJUnitTestCase[]\n}\n\ninterface IJUnitTestCase {\n classname: string\n name: string\n time: number\n result: IJUnitTestCaseResult\n systemOutput: string\n steps: IJUnitTestStep[]\n}\n\ninterface IJUnitTestCaseFailure {\n type: string\n message?: string\n detail: string\n}\n\ninterface IJUnitTestCaseResult {\n status: TestStepResultStatus\n failure?: IJUnitTestCaseFailure\n}\n\ninterface IJUnitTestStep {\n attachments: Attachment[]\n hidden: boolean\n keyword: string\n line: number\n name?: string\n result: TestStepResult\n time: number\n}\n\ninterface IBuildJUnitTestStepOptions {\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\nexport default class JunitFormatter extends Formatter {\n private readonly names: Record<string, string[]> = {}\n private readonly suiteName: string\n public static readonly documentation: string = 'Outputs JUnit report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.suiteName = valueOrDefault(\n options.parsedArgvOptions.junit?.suiteName,\n 'cucumber-js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n private getTestCases() {\n return this.eventDataCollector\n .getTestCaseAttempts()\n .filter((attempt) => !attempt.willBeRetried)\n }\n\n private getTestSteps(\n testCaseAttempt: ITestCaseAttempt,\n gherkinStepMap: Record<string, messages.Step>,\n pickleStepMap: Record<string, messages.PickleStep>\n ) {\n return testCaseAttempt.testCase.testSteps.map((testStep) => {\n const isBeforeHook = !doesHaveValue(testStep.pickleStepId)\n return this.getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n }\n\n private getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJUnitTestStepOptions): IJUnitTestStep {\n const data: Partial<IJUnitTestStep> = {}\n if (testStep.pickleStepId) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\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 data.result = testStepResult\n data.time = testStepResult.duration\n ? this.durationToSeconds(testStepResult.duration)\n : 0\n data.attachments = testStepAttachments\n return data as IJUnitTestStep\n }\n\n private getTestCaseResult(steps: IJUnitTestStep[]): IJUnitTestCaseResult {\n const { status, message, exception } = getWorstTestStepResult(\n steps.map((step) => step.result)\n )\n return {\n status,\n failure:\n message || exception\n ? {\n type: exception?.type,\n message: exception?.message,\n detail: message,\n }\n : undefined,\n }\n }\n\n private durationToSeconds(duration: Duration): number {\n const NANOS_IN_SECOND = 1_000_000_000\n return (\n (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND\n )\n }\n\n private nameOrDefault(name: string, fallbackSuffix: string): string {\n if (!name) {\n return `(unnamed ${fallbackSuffix})`\n }\n return name\n }\n\n private getTestCaseName(\n feature: Feature,\n rule: Rule | undefined,\n pickle: Pickle\n ) {\n const featureName = this.nameOrDefault(feature.name, 'feature')\n const pickleName = this.nameOrDefault(pickle.name, 'scenario')\n const testCaseName = rule\n ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName\n : pickleName\n if (!this.names[featureName]) {\n this.names[featureName] = []\n }\n let index = 0\n while (\n this.names[featureName].includes(\n index > 0 ? `${testCaseName} [${index}]` : testCaseName\n )\n ) {\n index++\n }\n const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName\n this.names[featureName].push(name)\n return name\n }\n\n private formatTestSteps(steps: IJUnitTestStep[]): string {\n return steps\n .filter((step) => !step.hidden)\n .map((step) => {\n const statusText = step.result.status.toLowerCase()\n const maxLength = 80 - statusText.length - 3\n const stepText = `${step.keyword}${step.name}`\n .padEnd(maxLength, '.')\n .substring(0, maxLength)\n return `${stepText}...${statusText}`\n })\n .join('\\n')\n }\n\n private onTestRunFinished(): void {\n const testCases = this.getTestCases()\n\n const tests = testCases.map<IJUnitTestCase>(\n (testCaseAttempt: ITestCaseAttempt) => {\n const { gherkinDocument, pickle } = testCaseAttempt\n const { feature } = gherkinDocument\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n\n const steps = this.getTestSteps(\n testCaseAttempt,\n gherkinStepMap,\n pickleStepMap\n )\n const stepDuration = steps.reduce(\n (total, step) => total + (step.time || 0),\n 0\n )\n\n return {\n classname: this.nameOrDefault(feature.name, 'feature'),\n name: this.getTestCaseName(feature, rule, pickle),\n time: stepDuration,\n result: this.getTestCaseResult(steps),\n systemOutput: this.formatTestSteps(steps),\n steps,\n }\n }\n )\n\n const passed = tests.filter(\n (item) => item.result.status === TestStepResultStatus.PASSED\n ).length\n const skipped = tests.filter(\n (item) => item.result.status === TestStepResultStatus.SKIPPED\n ).length\n const failures = tests.length - passed - skipped\n\n const testSuite: IJUnitTestSuite = {\n name: this.suiteName,\n tests,\n failures,\n skipped,\n time: tests.reduce((total, test) => total + test.time, 0),\n }\n\n this.log(this.buildXmlReport(testSuite))\n }\n\n private buildXmlReport(testSuite: IJUnitTestSuite): string {\n const xmlReport = xmlbuilder\n .create('testsuite', { invalidCharReplacement: '' })\n .att('failures', testSuite.failures)\n .att('skipped', testSuite.skipped)\n .att('name', testSuite.name)\n .att('time', testSuite.time)\n .att('tests', testSuite.tests.length)\n testSuite.tests.forEach((test) => {\n const xmlTestCase = xmlReport.ele('testcase', {\n classname: test.classname,\n name: test.name,\n time: test.time,\n })\n if (test.result.status === TestStepResultStatus.SKIPPED) {\n xmlTestCase.ele('skipped')\n } else if (test.result.status !== TestStepResultStatus.PASSED) {\n const xmlFailure = xmlTestCase.ele('failure', {\n type: test.result.failure?.type,\n message: test.result.failure?.message,\n })\n if (test.result?.failure) {\n xmlFailure.cdata(test.result.failure.detail)\n }\n }\n xmlTestCase.ele('system-out', {}).cdata(test.systemOutput)\n })\n\n return xmlReport.end({ pretty: true })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"junit_formatter.js","sourceRoot":"","sources":["../../src/formatter/junit_formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAEnC,iDAS2B;AAC3B,oDAAgD;AAChD,oDAAiD;AAEjD,+EAG0C;AAC1C,2DAA0E;AAC1E,0CAAiD;AAiDjD,MAAqB,cAAe,SAAQ,UAAS;IAClC,KAAK,GAA6B,EAAE,CAAA;IACpC,SAAS,CAAQ;IAC3B,MAAM,CAAU,aAAa,GAAW,sBAAsB,CAAA;IAErE,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,C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AAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;;AA5NH,iCA6NC","sourcesContent":["import xmlbuilder from 'xmlbuilder'\nimport * as messages from '@cucumber/messages'\nimport {\n Attachment,\n Duration,\n Feature,\n getWorstTestStepResult,\n Pickle,\n Rule,\n TestStepResult,\n TestStepResultStatus,\n} from '@cucumber/messages'\nimport { doesHaveValue } from '../value_checker'\nimport { valueOrDefault } from '../value_checker'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport {\n getGherkinExampleRuleMap,\n getGherkinStepMap,\n} from './helpers/gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './helpers/pickle_parser'\nimport Formatter, { IFormatterOptions } from './'\n\ninterface IJUnitTestSuite {\n name: string\n failures: number\n skipped: number\n time: number\n tests: IJUnitTestCase[]\n}\n\ninterface IJUnitTestCase {\n classname: string\n name: string\n time: number\n result: IJUnitTestCaseResult\n systemOutput: string\n steps: IJUnitTestStep[]\n}\n\ninterface IJUnitTestCaseFailure {\n type: string\n message?: string\n detail: string\n}\n\ninterface IJUnitTestCaseResult {\n status: TestStepResultStatus\n failure?: IJUnitTestCaseFailure\n}\n\ninterface IJUnitTestStep {\n attachments: Attachment[]\n hidden: boolean\n keyword: string\n line: number\n name?: string\n result: TestStepResult\n time: number\n}\n\ninterface IBuildJUnitTestStepOptions {\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\nexport default class JunitFormatter extends Formatter {\n private readonly names: Record<string, string[]> = {}\n private readonly suiteName: string\n public static readonly documentation: string = 'Outputs JUnit report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.suiteName = valueOrDefault(\n options.parsedArgvOptions.junit?.suiteName,\n 'cucumber-js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n private getTestCases() {\n return this.eventDataCollector\n .getTestCaseAttempts()\n .filter((attempt) => !attempt.willBeRetried)\n }\n\n private getTestSteps(\n testCaseAttempt: ITestCaseAttempt,\n gherkinStepMap: Record<string, messages.Step>,\n pickleStepMap: Record<string, messages.PickleStep>\n ) {\n return testCaseAttempt.testCase.testSteps.map((testStep) => {\n const isBeforeHook = !doesHaveValue(testStep.pickleStepId)\n return this.getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n }\n\n private getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJUnitTestStepOptions): IJUnitTestStep {\n const data: Partial<IJUnitTestStep> = {}\n if (testStep.pickleStepId) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\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 data.result = testStepResult\n data.time = testStepResult.duration\n ? this.durationToSeconds(testStepResult.duration)\n : 0\n data.attachments = testStepAttachments\n return data as IJUnitTestStep\n }\n\n private getTestCaseResult(steps: IJUnitTestStep[]): IJUnitTestCaseResult {\n const { status, message, exception } = getWorstTestStepResult(\n steps.map((step) => step.result)\n )\n return {\n status,\n failure:\n message || exception\n ? {\n type: exception?.type,\n message: exception?.message,\n detail: message,\n }\n : undefined,\n }\n }\n\n private durationToSeconds(duration: Duration): number {\n const NANOS_IN_SECOND = 1_000_000_000\n return (\n (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND\n )\n }\n\n private nameOrDefault(name: string, fallbackSuffix: string): string {\n if (!name) {\n return `(unnamed ${fallbackSuffix})`\n }\n return name\n }\n\n private getTestCaseName(\n feature: Feature,\n rule: Rule | undefined,\n pickle: Pickle\n ) {\n const featureName = this.nameOrDefault(feature.name, 'feature')\n const pickleName = this.nameOrDefault(pickle.name, 'scenario')\n const testCaseName = rule\n ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName\n : pickleName\n if (!this.names[featureName]) {\n this.names[featureName] = []\n }\n let index = 0\n while (\n this.names[featureName].includes(\n index > 0 ? `${testCaseName} [${index}]` : testCaseName\n )\n ) {\n index++\n }\n const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName\n this.names[featureName].push(name)\n return name\n }\n\n private formatTestSteps(steps: IJUnitTestStep[]): string {\n return steps\n .filter((step) => !step.hidden)\n .map((step) => {\n const statusText = step.result.status.toLowerCase()\n const maxLength = 80 - statusText.length - 3\n const stepText = `${step.keyword}${step.name}`\n .padEnd(maxLength, '.')\n .substring(0, maxLength)\n return `${stepText}...${statusText}`\n })\n .join('\\n')\n }\n\n private onTestRunFinished(): void {\n const testCases = this.getTestCases()\n\n const tests = testCases.map<IJUnitTestCase>(\n (testCaseAttempt: ITestCaseAttempt) => {\n const { gherkinDocument, pickle } = testCaseAttempt\n const { feature } = gherkinDocument\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n\n const steps = this.getTestSteps(\n testCaseAttempt,\n gherkinStepMap,\n pickleStepMap\n )\n const stepDuration = steps.reduce(\n (total, step) => total + (step.time || 0),\n 0\n )\n\n return {\n classname: this.nameOrDefault(feature.name, 'feature'),\n name: this.getTestCaseName(feature, rule, pickle),\n time: stepDuration,\n result: this.getTestCaseResult(steps),\n systemOutput: this.formatTestSteps(steps),\n steps,\n }\n }\n )\n\n const passed = tests.filter(\n (item) => item.result.status === TestStepResultStatus.PASSED\n ).length\n const skipped = tests.filter(\n (item) => item.result.status === TestStepResultStatus.SKIPPED\n ).length\n const failures = tests.length - passed - skipped\n\n const testSuite: IJUnitTestSuite = {\n name: this.suiteName,\n tests,\n failures,\n skipped,\n time: tests.reduce((total, test) => total + test.time, 0),\n }\n\n this.log(this.buildXmlReport(testSuite))\n }\n\n private buildXmlReport(testSuite: IJUnitTestSuite): string {\n const xmlReport = xmlbuilder\n .create('testsuite', { invalidCharReplacement: '' })\n .att('failures', testSuite.failures)\n .att('skipped', testSuite.skipped)\n .att('name', testSuite.name)\n .att('time', testSuite.time)\n .att('tests', testSuite.tests.length)\n testSuite.tests.forEach((test) => {\n const xmlTestCase = xmlReport.ele('testcase', {\n classname: test.classname,\n name: test.name,\n time: test.time,\n })\n if (test.result.status === TestStepResultStatus.SKIPPED) {\n xmlTestCase.ele('skipped')\n } else if (test.result.status !== TestStepResultStatus.PASSED) {\n const xmlFailure = xmlTestCase.ele('failure', {\n type: test.result.failure?.type,\n message: test.result.failure?.message,\n })\n if (test.result?.failure) {\n xmlFailure.cdata(test.result.failure.detail)\n }\n }\n xmlTestCase.ele('system-out', {}).cdata(test.systemOutput)\n })\n\n return xmlReport.end({ pretty: true })\n }\n}\n"]}
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const _1 = __importDefault(require("."));
|
|
7
7
|
class MessageFormatter extends _1.default {
|
|
8
|
+
static documentation = 'Outputs protobuf messages';
|
|
8
9
|
constructor(options) {
|
|
9
10
|
super(options);
|
|
10
11
|
options.eventBroadcaster.on('envelope', (envelope) => this.log(JSON.stringify(envelope) + '\n'));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.default = MessageFormatter;
|
|
14
|
-
MessageFormatter.documentation = 'Outputs protobuf messages';
|
|
15
15
|
//# sourceMappingURL=message_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AACA,yCAAgD;AAEhD,MAAqB,gBAAiB,SAAQ,UAAS;IAC9C,MAAM,CAAU,aAAa,GAAW,2BAA2B,CAAA;IAC1E,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;;AAPH,mCAQC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport Formatter, { IFormatterOptions } from '.'\n\nexport default class MessageFormatter extends Formatter {\n public static readonly documentation: string = 'Outputs protobuf messages'\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
|
-
import Formatter, { IFormatterOptions } from './';
|
|
2
1
|
import ProgressBar from 'progress';
|
|
3
2
|
import * as messages from '@cucumber/messages';
|
|
3
|
+
import Formatter, { IFormatterOptions } from './';
|
|
4
4
|
export default class ProgressBarFormatter extends Formatter {
|
|
5
5
|
private numberOfSteps;
|
|
6
6
|
private testRunStarted;
|
|
@@ -3,14 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const helpers_1 = require("./helpers");
|
|
7
|
-
const _1 = __importDefault(require("./"));
|
|
8
6
|
const progress_1 = __importDefault(require("progress"));
|
|
9
7
|
const value_checker_1 = require("../value_checker");
|
|
10
|
-
const issue_helpers_1 = require("./helpers/issue_helpers");
|
|
11
8
|
const time_1 = require("../time");
|
|
9
|
+
const issue_helpers_1 = require("./helpers/issue_helpers");
|
|
10
|
+
const helpers_1 = require("./helpers");
|
|
11
|
+
const _1 = __importDefault(require("./"));
|
|
12
12
|
// Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber
|
|
13
13
|
class ProgressBarFormatter extends _1.default {
|
|
14
|
+
numberOfSteps;
|
|
15
|
+
testRunStarted;
|
|
16
|
+
issueCount;
|
|
17
|
+
progressBar;
|
|
18
|
+
static documentation = 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run';
|
|
14
19
|
constructor(options) {
|
|
15
20
|
super(options);
|
|
16
21
|
options.eventBroadcaster.on('envelope', this.parseEnvelope.bind(this));
|
|
@@ -95,5 +100,4 @@ class ProgressBarFormatter extends _1.default {
|
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
exports.default = ProgressBarFormatter;
|
|
98
|
-
ProgressBarFormatter.documentation = 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run';
|
|
99
103
|
//# sourceMappingURL=progress_bar_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"progress_bar_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_bar_formatter.ts"],"names":[],"mappings":";;;;;AACA,wDAAkC;AAElC,oDAAgE;AAChE,kCAAmD;AACnD,2DAAsE;AACtE,uCAA+D;AAC/D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C","sourcesContent":["import { WriteStream as TtyWriteStream } from 'node:tty'\nimport ProgressBar from 'progress'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { durationBetweenTimestamps } from '../time'\nimport { formatUndefinedParameterType } from './helpers/issue_helpers'\nimport { formatIssue, formatSummary, isIssue } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\n\n// Inspired by https://github.com/thekompanee/fuubar and https://github.com/martinciu/fuubar-cucumber\nexport default class ProgressBarFormatter extends Formatter {\n private numberOfSteps: number\n private testRunStarted: messages.TestRunStarted\n private issueCount: number\n public progressBar: ProgressBar\n public static readonly documentation: string =\n 'Similar to the Progress Formatter, but provides a real-time updating progress bar based on the total number of steps to be executed in the test run'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n this.numberOfSteps = 0\n this.issueCount = 0\n }\n\n incrementStepCount(pickleId: string): void {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n this.numberOfSteps += pickle.steps.length\n }\n\n initializeProgressBar(): void {\n if (doesHaveValue(this.progressBar)) {\n return\n }\n this.progressBar = new ProgressBar(':current/:total steps [:bar] ', {\n clear: true,\n incomplete: ' ',\n stream: this.stream,\n total: this.numberOfSteps,\n width: valueOrDefault((this.stream as TtyWriteStream).columns, 80),\n })\n }\n\n logProgress({\n testStepId,\n testCaseStartedId,\n }: messages.TestStepFinished): void {\n const { testCase } =\n this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)\n const testStep = testCase.testSteps.find((s) => s.id === testStepId)\n if (doesHaveValue(testStep.pickleStepId)) {\n this.progressBar.tick()\n }\n }\n\n logUndefinedParametertype(\n parameterType: messages.UndefinedParameterType\n ): void {\n this.log(\n `Undefined parameter type: ${formatUndefinedParameterType(\n parameterType\n )}\\n`\n )\n }\n\n logErrorIfNeeded(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (isIssue(worstTestStepResult)) {\n this.issueCount += 1\n const testCaseAttempt = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n this.progressBar.interrupt(\n formatIssue({\n colorFns: this.colorFns,\n number: this.issueCount,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n printAttachments: this.printAttachments,\n })\n )\n if (testCaseFinished.willBeRetried) {\n const stepsToRetry = testCaseAttempt.pickle.steps.length\n this.progressBar.tick(-stepsToRetry)\n }\n }\n }\n\n logSummary(testRunFinished: messages.TestRunFinished): void {\n const testRunDuration = durationBetweenTimestamps(\n this.testRunStarted.timestamp,\n testRunFinished.timestamp\n )\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts: this.eventDataCollector.getTestCaseAttempts(),\n testRunDuration,\n })\n )\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.undefinedParameterType)) {\n this.logUndefinedParametertype(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.incrementStepCount(envelope.testCase.pickleId)\n } else if (doesHaveValue(envelope.testStepStarted)) {\n this.initializeProgressBar()\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.logErrorIfNeeded(envelope.testCaseFinished)\n } else if (doesHaveValue(envelope.testRunStarted)) {\n this.testRunStarted = envelope.testRunStarted\n } else if (doesHaveValue(envelope.testRunFinished)) {\n this.logSummary(envelope.testRunFinished)\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
1
2
|
import SummaryFormatter from './summary_formatter';
|
|
2
3
|
import { IFormatterOptions } from './index';
|
|
3
|
-
import * as messages from '@cucumber/messages';
|
|
4
4
|
import ITestStepFinished = messages.TestStepFinished;
|
|
5
5
|
export default class ProgressFormatter extends SummaryFormatter {
|
|
6
6
|
static readonly documentation: string;
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const summary_formatter_1 = __importDefault(require("./summary_formatter"));
|
|
30
|
-
const value_checker_1 = require("../value_checker");
|
|
31
29
|
const messages = __importStar(require("@cucumber/messages"));
|
|
30
|
+
const value_checker_1 = require("../value_checker");
|
|
31
|
+
const summary_formatter_1 = __importDefault(require("./summary_formatter"));
|
|
32
32
|
const STATUS_CHARACTER_MAPPING = new Map([
|
|
33
33
|
[messages.TestStepResultStatus.AMBIGUOUS, 'A'],
|
|
34
34
|
[messages.TestStepResultStatus.FAILED, 'F'],
|
|
@@ -38,6 +38,7 @@ const STATUS_CHARACTER_MAPPING = new Map([
|
|
|
38
38
|
[messages.TestStepResultStatus.UNDEFINED, 'U'],
|
|
39
39
|
]);
|
|
40
40
|
class ProgressFormatter extends summary_formatter_1.default {
|
|
41
|
+
static documentation = 'Prints one character per scenario.';
|
|
41
42
|
constructor(options) {
|
|
42
43
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
43
44
|
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
@@ -55,5 +56,4 @@ class ProgressFormatter extends summary_formatter_1.default {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
exports.default = ProgressFormatter;
|
|
58
|
-
ProgressFormatter.documentation = 'Prints one character per scenario.';
|
|
59
59
|
//# sourceMappingURL=progress_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"progress_formatter.js","sourceR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,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CACrC,CAAA;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrB,CAAC;;AApBH,oCAqBC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { doesHaveValue } from '../value_checker'\nimport SummaryFormatter from './summary_formatter'\nimport { IFormatterOptions } from './index'\nimport IEnvelope = messages.Envelope\nimport ITestStepFinished = messages.TestStepFinished\n\nconst STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =\n new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, 'A'],\n [messages.TestStepResultStatus.FAILED, 'F'],\n [messages.TestStepResultStatus.PASSED, '.'],\n [messages.TestStepResultStatus.PENDING, 'P'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, 'U'],\n ])\n\nexport default class ProgressFormatter extends SummaryFormatter {\n public static readonly documentation: string =\n 'Prints one character per scenario.'\n\n constructor(options: IFormatterOptions) {\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.log('\\n\\n')\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n }\n })\n super(options)\n }\n\n logProgress({ testStepResult: { status } }: ITestStepFinished): void {\n const character = this.colorFns.forStatus(status)(\n STATUS_CHARACTER_MAPPING.get(status)\n )\n this.log(character)\n }\n}\n"]}
|
|
@@ -26,15 +26,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const _1 = __importDefault(require("./"));
|
|
30
|
-
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
31
|
-
const value_checker_1 = require("../value_checker");
|
|
32
29
|
const messages = __importStar(require("@cucumber/messages"));
|
|
30
|
+
const value_checker_1 = require("../value_checker");
|
|
31
|
+
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
32
|
+
const _1 = __importDefault(require("./"));
|
|
33
33
|
const DEFAULT_SEPARATOR = '\n';
|
|
34
34
|
function isFailedAttempt(worstTestStepResult) {
|
|
35
35
|
return worstTestStepResult.status !== messages.TestStepResultStatus.PASSED;
|
|
36
36
|
}
|
|
37
37
|
class RerunFormatter extends _1.default {
|
|
38
|
+
separator;
|
|
39
|
+
static documentation = 'Prints failing files with line numbers.';
|
|
38
40
|
constructor(options) {
|
|
39
41
|
super(options);
|
|
40
42
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
@@ -76,5 +78,4 @@ class RerunFormatter extends _1.default {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
exports.default = RerunFormatter;
|
|
79
|
-
RerunFormatter.documentation = 'Prints failing files with line numbers.';
|
|
80
81
|
//# sourceMappingURL=rerun_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rerun_formatter.js","sourceRoot":"","sources":["../../src/formatter/rerun_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"rerun_formatter.js","sourceRoot":"","sources":["../../src/formatter/rerun_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,oDAIyB;AACzB,+EAAiF;AACjF,0CAAiD;AAEjD,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAM9B,SAAS,eAAe,CAAC,mBAA4C;IACnE,OAAO,mBAAmB,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;AAC5E,CAAC;AAED,MAAqB,cAAe,SAAQ,UAAS;IAChC,SAAS,CAAQ;IAC7B,MAAM,CAAU,aAAa,GAClC,yCAAyC,CAAA;IAE3C,YAAY,OAA0B;QACpC,KAAK,CAAC,OA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,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aACxB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;YAC1B,OAAO,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QACpC,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAED,kBAAkB;QAChB,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QACpD,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAC3B,CAAC;;AArDH,iCAsDC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\nimport { getGherkinScenarioLocationMap } from './helpers/gherkin_document_parser'\nimport Formatter, { IFormatterOptions } from './'\n\nconst DEFAULT_SEPARATOR = '\\n'\n\ninterface UriToLinesMap {\n [uri: string]: number[]\n}\n\nfunction isFailedAttempt(worstTestStepResult: messages.TestStepResult) {\n return worstTestStepResult.status !== messages.TestStepResultStatus.PASSED\n}\n\nexport default class RerunFormatter extends Formatter {\n protected readonly separator: string\n public static readonly documentation: string =\n 'Prints failing files with line numbers.'\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logFailedTestCases()\n }\n })\n const rerunOptions = valueOrDefault(options.parsedArgvOptions.rerun, {})\n this.separator = valueOrDefault(rerunOptions.separator, DEFAULT_SEPARATOR)\n }\n\n getFailureMap(): UriToLinesMap {\n const mapping: UriToLinesMap = {}\n this.eventDataCollector\n .getTestCaseAttempts()\n .forEach(\n ({ gherkinDocument, pickle, worstTestStepResult, willBeRetried }) => {\n if (isFailedAttempt(worstTestStepResult) && !willBeRetried) {\n const relativeUri = pickle.uri\n const line =\n getGherkinScenarioLocationMap(gherkinDocument)[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].line\n if (doesNotHaveValue(mapping[relativeUri])) {\n mapping[relativeUri] = []\n }\n mapping[relativeUri].push(line)\n }\n }\n )\n\n return mapping\n }\n\n formatFailedTestCases(): string {\n const mapping = this.getFailureMap()\n\n return Object.keys(mapping)\n .map((uri) => {\n const lines = mapping[uri]\n return `${uri}:${lines.join(':')}`\n })\n .join(this.separator)\n }\n\n logFailedTestCases(): void {\n const failedTestCases = this.formatFailedTestCases()\n this.log(failedTestCases)\n }\n}\n"]}
|
|
@@ -26,11 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const _1 = __importDefault(require("./"));
|
|
30
|
-
const helpers_1 = require("./helpers");
|
|
31
|
-
const value_checker_1 = require("../value_checker");
|
|
32
29
|
const messages = __importStar(require("@cucumber/messages"));
|
|
30
|
+
const value_checker_1 = require("../value_checker");
|
|
31
|
+
const helpers_1 = require("./helpers");
|
|
32
|
+
const _1 = __importDefault(require("./"));
|
|
33
33
|
class SnippetsFormatter extends _1.default {
|
|
34
|
+
static documentation = "The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps";
|
|
34
35
|
constructor(options) {
|
|
35
36
|
super(options);
|
|
36
37
|
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
@@ -57,5 +58,4 @@ class SnippetsFormatter extends _1.default {
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
exports.default = SnippetsFormatter;
|
|
60
|
-
SnippetsFormatter.documentation = "The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps";
|
|
61
61
|
//# sourceMappingURL=snippets_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,oDAAgD;AAChD,uCAAgD;AAChD,0CAAiD;AAGjD,MAAqB,iBAAkB,SAAQ,UAAS;IAC/C,MAAM,CAAU,aAAa,GAClC,iIAAiI,CAAA;IAEnI,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC;gBAClC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;aAChB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,IACE,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAClE;oBACA,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,CAAC;;AA9BH,oCA+BC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { doesHaveValue } from '../value_checker'\nimport { parseTestCaseAttempt } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport IEnvelope = messages.Envelope\n\nexport default class SnippetsFormatter extends Formatter {\n public static readonly documentation: string =\n \"The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps\"\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logSnippets()\n }\n })\n }\n\n logSnippets(): void {\n const snippets: string[] = []\n this.eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {\n const parsed = parseTestCaseAttempt({\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n parsed.testSteps.forEach((testStep) => {\n if (\n testStep.result.status === messages.TestStepResultStatus.UNDEFINED\n ) {\n snippets.push(testStep.snippet)\n }\n })\n })\n this.log(snippets.join('\\n\\n'))\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { KeywordType } from '../helpers';
|
|
2
|
-
import { ISnippetSnytax } from './snippet_syntax';
|
|
3
1
|
import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
|
|
4
2
|
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { KeywordType } from '../helpers';
|
|
4
|
+
import { ISnippetSnytax } from './snippet_syntax';
|
|
5
5
|
export interface INewStepDefinitionSnippetBuilderOptions {
|
|
6
6
|
snippetSyntax: ISnippetSnytax;
|
|
7
7
|
parameterTypeRegistry: ParameterTypeRegistry;
|