@dev-blinq/cucumber-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +124 -0
- package/api/index.d.ts +6 -0
- package/bin/cucumber-js +3 -0
- package/bin/cucumber.js +3 -0
- package/lib/api/console_logger.d.ts +12 -0
- package/lib/api/console_logger.js +24 -0
- package/lib/api/console_logger.js.map +1 -0
- package/lib/api/convert_configuration.d.ts +4 -0
- package/lib/api/convert_configuration.js +65 -0
- package/lib/api/convert_configuration.js.map +1 -0
- package/lib/api/environment.d.ts +2 -0
- package/lib/api/environment.js +14 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +20 -0
- package/lib/api/formatters.js +61 -0
- package/lib/api/formatters.js.map +1 -0
- package/lib/api/gherkin.d.ts +21 -0
- package/lib/api/gherkin.js +65 -0
- package/lib/api/gherkin.js.map +1 -0
- package/lib/api/index.d.ts +12 -0
- package/lib/api/index.js +28 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load_configuration.d.ts +9 -0
- package/lib/api/load_configuration.js +41 -0
- package/lib/api/load_configuration.js.map +1 -0
- package/lib/api/load_sources.d.ts +9 -0
- package/lib/api/load_sources.js +53 -0
- package/lib/api/load_sources.js.map +1 -0
- package/lib/api/load_support.d.ts +10 -0
- package/lib/api/load_support.js +30 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +8 -0
- package/lib/api/paths.js +102 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/plugins.d.ts +4 -0
- package/lib/api/plugins.js +19 -0
- package/lib/api/plugins.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +115 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +21 -0
- package/lib/api/runtime.js +36 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/support.d.ts +9 -0
- package/lib/api/support.js +26 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/test_helpers.d.ts +3 -0
- package/lib/api/test_helpers.js +36 -0
- package/lib/api/test_helpers.js.map +1 -0
- package/lib/api/types.d.ts +175 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/cli/helpers.d.ts +37 -0
- package/lib/cli/helpers.js +203 -0
- package/lib/cli/helpers.js.map +1 -0
- package/lib/cli/i18n.d.ts +2 -0
- package/lib/cli/i18n.js +70 -0
- package/lib/cli/i18n.js.map +1 -0
- package/lib/cli/index.d.ts +21 -0
- package/lib/cli/index.js +59 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/install_validator.d.ts +1 -0
- package/lib/cli/install_validator.js +18 -0
- package/lib/cli/install_validator.js.map +1 -0
- package/lib/cli/run.d.ts +1 -0
- package/lib/cli/run.js +44 -0
- package/lib/cli/run.js.map +1 -0
- package/lib/cli/validate_node_engine_version.d.ts +10 -0
- package/lib/cli/validate_node_engine_version.js +24 -0
- package/lib/cli/validate_node_engine_version.js.map +1 -0
- package/lib/configuration/argv_parser.d.ts +20 -0
- package/lib/configuration/argv_parser.js +102 -0
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/check_schema.d.ts +2 -0
- package/lib/configuration/check_schema.js +60 -0
- package/lib/configuration/check_schema.js.map +1 -0
- package/lib/configuration/default_configuration.d.ts +2 -0
- package/lib/configuration/default_configuration.js +27 -0
- package/lib/configuration/default_configuration.js.map +1 -0
- package/lib/configuration/from_file.d.ts +3 -0
- package/lib/configuration/from_file.js +85 -0
- package/lib/configuration/from_file.js.map +1 -0
- package/lib/configuration/helpers.d.ts +1 -0
- package/lib/configuration/helpers.js +11 -0
- package/lib/configuration/helpers.js.map +1 -0
- package/lib/configuration/index.d.ts +7 -0
- package/lib/configuration/index.js +29 -0
- package/lib/configuration/index.js.map +1 -0
- package/lib/configuration/locate_file.d.ts +1 -0
- package/lib/configuration/locate_file.js +21 -0
- package/lib/configuration/locate_file.js.map +1 -0
- package/lib/configuration/merge_configurations.d.ts +2 -0
- package/lib/configuration/merge_configurations.js +48 -0
- package/lib/configuration/merge_configurations.js.map +1 -0
- package/lib/configuration/option_splitter.d.ts +3 -0
- package/lib/configuration/option_splitter.js +23 -0
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +28 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +3 -0
- package/lib/configuration/validate_configuration.js +13 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/filter_stack_trace.d.ts +3 -0
- package/lib/filter_stack_trace.js +38 -0
- package/lib/filter_stack_trace.js.map +1 -0
- package/lib/formatter/builder.d.ts +37 -0
- package/lib/formatter/builder.js +101 -0
- package/lib/formatter/builder.js.map +1 -0
- package/lib/formatter/fixtures/typescript.d.ts +2 -0
- package/lib/formatter/fixtures/typescript.js +6 -0
- package/lib/formatter/fixtures/typescript.js.map +1 -0
- package/lib/formatter/get_color_fns.d.ts +15 -0
- package/lib/formatter/get_color_fns.js +56 -0
- package/lib/formatter/get_color_fns.js.map +1 -0
- package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
- package/lib/formatter/helpers/duration_helpers.js +9 -0
- package/lib/formatter/helpers/duration_helpers.js.map +1 -0
- package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
- package/lib/formatter/helpers/event_data_collector.js +126 -0
- package/lib/formatter/helpers/event_data_collector.js.map +1 -0
- package/lib/formatter/helpers/formatters.d.ts +6 -0
- package/lib/formatter/helpers/formatters.js +43 -0
- package/lib/formatter/helpers/formatters.js.map +1 -0
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
- package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
- package/lib/formatter/helpers/index.d.ts +10 -0
- package/lib/formatter/helpers/index.js +52 -0
- package/lib/formatter/helpers/index.js.map +1 -0
- package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
- package/lib/formatter/helpers/issue_helpers.js +59 -0
- package/lib/formatter/helpers/issue_helpers.js.map +1 -0
- package/lib/formatter/helpers/keyword_type.d.ts +11 -0
- package/lib/formatter/helpers/keyword_type.js +32 -0
- package/lib/formatter/helpers/keyword_type.js.map +1 -0
- package/lib/formatter/helpers/location_helpers.d.ts +2 -0
- package/lib/formatter/helpers/location_helpers.js +17 -0
- package/lib/formatter/helpers/location_helpers.js.map +1 -0
- package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
- package/lib/formatter/helpers/pickle_parser.js +28 -0
- package/lib/formatter/helpers/pickle_parser.js.map +1 -0
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
- package/lib/formatter/helpers/step_argument_formatter.js +48 -0
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
- package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
- package/lib/formatter/helpers/summary_helpers.js +96 -0
- package/lib/formatter/helpers/summary_helpers.js.map +1 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
- package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
- package/lib/formatter/helpers/usage_helpers/index.js +111 -0
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
- package/lib/formatter/html_formatter.d.ts +7 -0
- package/lib/formatter/html_formatter.js +30 -0
- package/lib/formatter/html_formatter.js.map +1 -0
- package/lib/formatter/index.d.ts +53 -0
- package/lib/formatter/index.js +21 -0
- package/lib/formatter/index.js.map +1 -0
- package/lib/formatter/json_formatter.d.ts +78 -0
- package/lib/formatter/json_formatter.js +230 -0
- package/lib/formatter/json_formatter.js.map +1 -0
- package/lib/formatter/junit_formatter.d.ts +17 -0
- package/lib/formatter/junit_formatter.js +181 -0
- package/lib/formatter/junit_formatter.js.map +1 -0
- package/lib/formatter/message_formatter.d.ts +5 -0
- package/lib/formatter/message_formatter.js +15 -0
- package/lib/formatter/message_formatter.js.map +1 -0
- package/lib/formatter/progress_bar_formatter.d.ts +18 -0
- package/lib/formatter/progress_bar_formatter.js +99 -0
- package/lib/formatter/progress_bar_formatter.js.map +1 -0
- package/lib/formatter/progress_formatter.d.ts +9 -0
- package/lib/formatter/progress_formatter.js +59 -0
- package/lib/formatter/progress_formatter.js.map +1 -0
- package/lib/formatter/rerun_formatter.d.ts +13 -0
- package/lib/formatter/rerun_formatter.js +80 -0
- package/lib/formatter/rerun_formatter.js.map +1 -0
- package/lib/formatter/snippets_formatter.d.ts +6 -0
- package/lib/formatter/snippets_formatter.js +61 -0
- package/lib/formatter/snippets_formatter.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
- package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
- package/lib/formatter/summary_formatter.d.ts +14 -0
- package/lib/formatter/summary_formatter.js +68 -0
- package/lib/formatter/summary_formatter.js.map +1 -0
- package/lib/formatter/usage_formatter.d.ts +6 -0
- package/lib/formatter/usage_formatter.js +98 -0
- package/lib/formatter/usage_formatter.js.map +1 -0
- package/lib/formatter/usage_json_formatter.d.ts +7 -0
- package/lib/formatter/usage_json_formatter.js +34 -0
- package/lib/formatter/usage_json_formatter.js.map +1 -0
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +58 -0
- package/lib/index.js +109 -0
- package/lib/index.js.map +1 -0
- package/lib/logger.d.ts +5 -0
- package/lib/logger.js +3 -0
- package/lib/logger.js.map +1 -0
- package/lib/models/data_table.d.ts +10 -0
- package/lib/models/data_table.js +46 -0
- package/lib/models/data_table.js.map +1 -0
- package/lib/models/definition.d.ts +55 -0
- package/lib/models/definition.js +22 -0
- package/lib/models/definition.js.map +1 -0
- package/lib/models/gherkin_step_keyword.d.ts +1 -0
- package/lib/models/gherkin_step_keyword.js +3 -0
- package/lib/models/gherkin_step_keyword.js.map +1 -0
- package/lib/models/pickle_order.d.ts +1 -0
- package/lib/models/pickle_order.js +3 -0
- package/lib/models/pickle_order.js.map +1 -0
- package/lib/models/step_definition.d.ts +11 -0
- package/lib/models/step_definition.js +37 -0
- package/lib/models/step_definition.js.map +1 -0
- package/lib/models/test_case_hook_definition.d.ts +10 -0
- package/lib/models/test_case_hook_definition.js +27 -0
- package/lib/models/test_case_hook_definition.js.map +1 -0
- package/lib/models/test_run_hook_definition.d.ts +3 -0
- package/lib/models/test_run_hook_definition.js +10 -0
- package/lib/models/test_run_hook_definition.js.map +1 -0
- package/lib/models/test_step_hook_definition.d.ts +9 -0
- package/lib/models/test_step_hook_definition.js +26 -0
- package/lib/models/test_step_hook_definition.js.map +1 -0
- package/lib/pickle_filter.d.ts +42 -0
- package/lib/pickle_filter.js +99 -0
- package/lib/pickle_filter.js.map +1 -0
- package/lib/plugin/index.d.ts +2 -0
- package/lib/plugin/index.js +19 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +13 -0
- package/lib/plugin/plugin_manager.js +36 -0
- package/lib/plugin/plugin_manager.js.map +1 -0
- package/lib/plugin/types.d.ts +14 -0
- package/lib/plugin/types.js +3 -0
- package/lib/plugin/types.js.map +1 -0
- package/lib/publish/http_stream.d.ts +30 -0
- package/lib/publish/http_stream.js +112 -0
- package/lib/publish/http_stream.js.map +1 -0
- package/lib/publish/index.d.ts +2 -0
- package/lib/publish/index.js +5 -0
- package/lib/publish/index.js.map +1 -0
- package/lib/publish/publish_plugin.d.ts +2 -0
- package/lib/publish/publish_plugin.js +48 -0
- package/lib/publish/publish_plugin.js.map +1 -0
- package/lib/runtime/assemble_test_cases.d.ts +13 -0
- package/lib/runtime/assemble_test_cases.js +88 -0
- package/lib/runtime/assemble_test_cases.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +33 -0
- package/lib/runtime/attachment_manager/index.js +119 -0
- package/lib/runtime/attachment_manager/index.js.map +1 -0
- package/lib/runtime/format_error.d.ts +2 -0
- package/lib/runtime/format_error.js +36 -0
- package/lib/runtime/format_error.js.map +1 -0
- package/lib/runtime/helpers.d.ts +6 -0
- package/lib/runtime/helpers.js +101 -0
- package/lib/runtime/helpers.js.map +1 -0
- package/lib/runtime/index.d.ts +40 -0
- package/lib/runtime/index.js +76 -0
- package/lib/runtime/index.js.map +1 -0
- package/lib/runtime/parallel/command_types.d.ts +32 -0
- package/lib/runtime/parallel/command_types.js +3 -0
- package/lib/runtime/parallel/command_types.js.map +1 -0
- package/lib/runtime/parallel/coordinator.d.ts +72 -0
- package/lib/runtime/parallel/coordinator.js +222 -0
- package/lib/runtime/parallel/coordinator.js.map +1 -0
- package/lib/runtime/parallel/run_worker.d.ts +1 -0
- package/lib/runtime/parallel/run_worker.js +29 -0
- package/lib/runtime/parallel/run_worker.js.map +1 -0
- package/lib/runtime/parallel/worker.d.ts +26 -0
- package/lib/runtime/parallel/worker.js +87 -0
- package/lib/runtime/parallel/worker.js.map +1 -0
- package/lib/runtime/run_test_run_hooks.d.ts +3 -0
- package/lib/runtime/run_test_run_hooks.js +28 -0
- package/lib/runtime/run_test_run_hooks.js.map +1 -0
- package/lib/runtime/step_runner.d.ts +16 -0
- package/lib/runtime/step_runner.js +88 -0
- package/lib/runtime/step_runner.js.map +1 -0
- package/lib/runtime/stopwatch.d.ts +12 -0
- package/lib/runtime/stopwatch.js +34 -0
- package/lib/runtime/stopwatch.js.map +1 -0
- package/lib/runtime/test_case_runner.d.ts +54 -0
- package/lib/runtime/test_case_runner.js +268 -0
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/step_arguments.d.ts +6 -0
- package/lib/step_arguments.js +19 -0
- package/lib/step_arguments.js.map +1 -0
- package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
- package/lib/support_code_library_builder/build_parameter_type.js +13 -0
- package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +29 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +74 -0
- package/lib/support_code_library_builder/index.js +304 -0
- package/lib/support_code_library_builder/index.js.map +1 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
- package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -0
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +88 -0
- package/lib/support_code_library_builder/types.js +3 -0
- package/lib/support_code_library_builder/types.js.map +1 -0
- package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
- package/lib/support_code_library_builder/validate_arguments.js +73 -0
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
- package/lib/support_code_library_builder/world.d.ts +18 -0
- package/lib/support_code_library_builder/world.js +11 -0
- package/lib/support_code_library_builder/world.js.map +1 -0
- package/lib/time.d.ts +18 -0
- package/lib/time.js +61 -0
- package/lib/time.js.map +1 -0
- package/lib/try_require.d.ts +7 -0
- package/lib/try_require.js +26 -0
- package/lib/try_require.js.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib/uncaught_exception_manager.d.ts +7 -0
- package/lib/uncaught_exception_manager.js +12 -0
- package/lib/uncaught_exception_manager.js.map +1 -0
- package/lib/user_code_runner.d.ts +14 -0
- package/lib/user_code_runner.js +82 -0
- package/lib/user_code_runner.js.map +1 -0
- package/lib/value_checker.d.ts +3 -0
- package/lib/value_checker.js +19 -0
- package/lib/value_checker.js.map +1 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +44 -0
- package/package.json +189 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IColorFns } from '../get_color_fns';
|
|
2
|
+
import { ITestCaseAttempt } from './event_data_collector';
|
|
3
|
+
import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder';
|
|
4
|
+
import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
5
|
+
export interface IFormatTestCaseAttemptRequest {
|
|
6
|
+
colorFns: IColorFns;
|
|
7
|
+
testCaseAttempt: ITestCaseAttempt;
|
|
8
|
+
snippetBuilder: StepDefinitionSnippetBuilder;
|
|
9
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
10
|
+
printAttachments?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function formatTestCaseAttempt({ colorFns, snippetBuilder, supportCodeLibrary, testCaseAttempt, printAttachments, }: IFormatTestCaseAttemptRequest): string;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.formatTestCaseAttempt = void 0;
|
|
30
|
+
const indent_string_1 = __importDefault(require("indent-string"));
|
|
31
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
32
|
+
const figures_1 = __importDefault(require("figures"));
|
|
33
|
+
const location_helpers_1 = require("./location_helpers");
|
|
34
|
+
const test_case_attempt_parser_1 = require("./test_case_attempt_parser");
|
|
35
|
+
const step_argument_formatter_1 = require("./step_argument_formatter");
|
|
36
|
+
const value_checker_1 = require("../../value_checker");
|
|
37
|
+
const CHARACTERS = new Map([
|
|
38
|
+
[messages.TestStepResultStatus.AMBIGUOUS, figures_1.default.cross],
|
|
39
|
+
[messages.TestStepResultStatus.FAILED, figures_1.default.cross],
|
|
40
|
+
[messages.TestStepResultStatus.PASSED, figures_1.default.tick],
|
|
41
|
+
[messages.TestStepResultStatus.PENDING, '?'],
|
|
42
|
+
[messages.TestStepResultStatus.SKIPPED, '-'],
|
|
43
|
+
[messages.TestStepResultStatus.UNDEFINED, '?'],
|
|
44
|
+
]);
|
|
45
|
+
function getStepMessage(testStep) {
|
|
46
|
+
switch (testStep.result.status) {
|
|
47
|
+
case messages.TestStepResultStatus.AMBIGUOUS:
|
|
48
|
+
case messages.TestStepResultStatus.FAILED:
|
|
49
|
+
return testStep.result.message;
|
|
50
|
+
case messages.TestStepResultStatus.UNDEFINED:
|
|
51
|
+
return `${'Undefined. Implement with the following snippet:' + '\n\n'}${(0, indent_string_1.default)(testStep.snippet, 2)}\n`;
|
|
52
|
+
case messages.TestStepResultStatus.PENDING:
|
|
53
|
+
return 'Pending';
|
|
54
|
+
}
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
function formatStep({ colorFns, testStep, printAttachments, }) {
|
|
58
|
+
const { name, result: { status }, actionLocation, attachments, } = testStep;
|
|
59
|
+
const colorFn = colorFns.forStatus(status);
|
|
60
|
+
const identifier = testStep.keyword + (0, value_checker_1.valueOrDefault)(testStep.text, '');
|
|
61
|
+
let text = colorFn(`${CHARACTERS.get(status)} ${identifier}`);
|
|
62
|
+
if ((0, value_checker_1.doesHaveValue)(name)) {
|
|
63
|
+
text += colorFn(` (${name})`);
|
|
64
|
+
}
|
|
65
|
+
if ((0, value_checker_1.doesHaveValue)(actionLocation)) {
|
|
66
|
+
text += ` # ${colorFns.location((0, location_helpers_1.formatLocation)(actionLocation))}`;
|
|
67
|
+
}
|
|
68
|
+
text += '\n';
|
|
69
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.argument)) {
|
|
70
|
+
const argumentsText = (0, step_argument_formatter_1.formatStepArgument)(testStep.argument);
|
|
71
|
+
text += (0, indent_string_1.default)(`${colorFn(argumentsText)}\n`, 4);
|
|
72
|
+
}
|
|
73
|
+
if ((0, value_checker_1.valueOrDefault)(printAttachments, true)) {
|
|
74
|
+
attachments.forEach(({ body, mediaType, fileName }) => {
|
|
75
|
+
let message = '';
|
|
76
|
+
if (mediaType === 'text/plain') {
|
|
77
|
+
message = `: ${body}`;
|
|
78
|
+
}
|
|
79
|
+
else if (fileName) {
|
|
80
|
+
message = `: ${fileName}`;
|
|
81
|
+
}
|
|
82
|
+
text += (0, indent_string_1.default)(`Attachment (${mediaType})${message}\n`, 4);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const message = getStepMessage(testStep);
|
|
86
|
+
if (message !== '') {
|
|
87
|
+
text += `${(0, indent_string_1.default)(colorFn(message), 4)}\n`;
|
|
88
|
+
}
|
|
89
|
+
return text;
|
|
90
|
+
}
|
|
91
|
+
function formatTestCaseAttempt({ colorFns, snippetBuilder, supportCodeLibrary, testCaseAttempt, printAttachments, }) {
|
|
92
|
+
const parsed = (0, test_case_attempt_parser_1.parseTestCaseAttempt)({
|
|
93
|
+
snippetBuilder,
|
|
94
|
+
testCaseAttempt,
|
|
95
|
+
supportCodeLibrary,
|
|
96
|
+
});
|
|
97
|
+
let text = `Scenario: ${parsed.testCase.name}`;
|
|
98
|
+
text += getAttemptText(parsed.testCase.attempt, testCaseAttempt.willBeRetried);
|
|
99
|
+
text += ` # ${colorFns.location((0, location_helpers_1.formatLocation)(parsed.testCase.sourceLocation))}\n`;
|
|
100
|
+
parsed.testSteps.forEach((testStep) => {
|
|
101
|
+
text += formatStep({ colorFns, testStep, printAttachments });
|
|
102
|
+
});
|
|
103
|
+
return `${text}\n`;
|
|
104
|
+
}
|
|
105
|
+
exports.formatTestCaseAttempt = formatTestCaseAttempt;
|
|
106
|
+
function getAttemptText(attempt, willBeRetried) {
|
|
107
|
+
if (attempt > 0 || willBeRetried) {
|
|
108
|
+
const numberStr = (attempt + 1).toString();
|
|
109
|
+
const retriedStr = willBeRetried ? ', retried' : '';
|
|
110
|
+
return ` (attempt ${numberStr}${retriedStr})`;
|
|
111
|
+
}
|
|
112
|
+
return '';
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=test_case_attempt_formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_case_attempt_formatter.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAwC;AACxC,6DAA8C;AAC9C,sDAA6B;AAC7B,yDAAmD;AACnD,yEAGmC;AACnC,uEAA8D;AAE9D,uDAAmE;AAKnE,MAAM,UAAU,GAA+C,IAAI,GAAG,CAAC;IACrE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,iBAAO,CAAC,KAAK,CAAC;IACxD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,KAAK,CAAC;IACrD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAO,CAAC,IAAI,CAAC;IACpD,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEF,SAAS,cAAc,CAAC,QAAyB;IAC/C,QAAQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAC9B,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,CAAC;QAC7C,KAAK,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YACvC,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAA;QAChC,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS;YAC1C,OAAO,GACL,kDAAkD,GAAG,MACvD,GAAG,IAAA,uBAAY,EAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAA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AAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,IAAI,IAAI,CAAA;AACpB,CAAC;AArBD,sDAqBC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,aAAsB;IAC7D,IAAI,OAAO,GAAG,CAAC,IAAI,aAAa,EAAE;QAChC,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;QACnD,OAAO,aAAa,SAAS,GAAG,UAAU,GAAG,CAAA;KAC9C;IACD,OAAO,EAAE,CAAA;AACX,CAAC","sourcesContent":["import indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport figures from 'figures'\nimport { formatLocation } from './location_helpers'\nimport {\n IParsedTestStep,\n parseTestCaseAttempt,\n} from './test_case_attempt_parser'\nimport { formatStepArgument } from './step_argument_formatter'\nimport { IColorFns } from '../get_color_fns'\nimport { doesHaveValue, valueOrDefault } from '../../value_checker'\nimport { ITestCaseAttempt } from './event_data_collector'\nimport StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\n\nconst CHARACTERS: Map<messages.TestStepResultStatus, string> = new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, figures.cross],\n [messages.TestStepResultStatus.FAILED, figures.cross],\n [messages.TestStepResultStatus.PASSED, figures.tick],\n [messages.TestStepResultStatus.PENDING, '?'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, '?'],\n])\n\nfunction getStepMessage(testStep: IParsedTestStep): string {\n switch (testStep.result.status) {\n case messages.TestStepResultStatus.AMBIGUOUS:\n case messages.TestStepResultStatus.FAILED:\n return testStep.result.message\n case messages.TestStepResultStatus.UNDEFINED:\n return `${\n 'Undefined. Implement with the following snippet:' + '\\n\\n'\n }${indentString(testStep.snippet, 2)}\\n`\n case messages.TestStepResultStatus.PENDING:\n return 'Pending'\n }\n return ''\n}\n\ninterface IFormatStepRequest {\n colorFns: IColorFns\n testStep: IParsedTestStep\n printAttachments?: boolean\n}\n\nfunction formatStep({\n colorFns,\n testStep,\n printAttachments,\n}: IFormatStepRequest): string {\n const {\n name,\n result: { status },\n actionLocation,\n attachments,\n } = testStep\n const colorFn = colorFns.forStatus(status)\n const identifier = testStep.keyword + valueOrDefault(testStep.text, '')\n let text = colorFn(`${CHARACTERS.get(status)} ${identifier}`)\n if (doesHaveValue(name)) {\n text += colorFn(` (${name})`)\n }\n if (doesHaveValue(actionLocation)) {\n text += ` # ${colorFns.location(formatLocation(actionLocation))}`\n }\n text += '\\n'\n if (doesHaveValue(testStep.argument)) {\n const argumentsText = formatStepArgument(testStep.argument)\n text += indentString(`${colorFn(argumentsText)}\\n`, 4)\n }\n if (valueOrDefault(printAttachments, true)) {\n attachments.forEach(({ body, mediaType, fileName }) => {\n let message = ''\n if (mediaType === 'text/plain') {\n message = `: ${body}`\n } else if (fileName) {\n message = `: ${fileName}`\n }\n text += indentString(`Attachment (${mediaType})${message}\\n`, 4)\n })\n }\n const message = getStepMessage(testStep)\n if (message !== '') {\n text += `${indentString(colorFn(message), 4)}\\n`\n }\n return text\n}\n\nexport interface IFormatTestCaseAttemptRequest {\n colorFns: IColorFns\n testCaseAttempt: ITestCaseAttempt\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n printAttachments?: boolean\n}\n\nexport function formatTestCaseAttempt({\n colorFns,\n snippetBuilder,\n supportCodeLibrary,\n testCaseAttempt,\n printAttachments,\n}: IFormatTestCaseAttemptRequest): string {\n const parsed = parseTestCaseAttempt({\n snippetBuilder,\n testCaseAttempt,\n supportCodeLibrary,\n })\n let text = `Scenario: ${parsed.testCase.name}`\n text += getAttemptText(parsed.testCase.attempt, testCaseAttempt.willBeRetried)\n text += ` # ${colorFns.location(\n formatLocation(parsed.testCase.sourceLocation)\n )}\\n`\n parsed.testSteps.forEach((testStep) => {\n text += formatStep({ colorFns, testStep, printAttachments })\n })\n return `${text}\\n`\n}\n\nfunction getAttemptText(attempt: number, willBeRetried: boolean): string {\n if (attempt > 0 || willBeRetried) {\n const numberStr = (attempt + 1).toString()\n const retriedStr = willBeRetried ? ', retried' : ''\n return ` (attempt ${numberStr}${retriedStr})`\n }\n return ''\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
|
+
import { ITestCaseAttempt } from './event_data_collector';
|
|
3
|
+
import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder';
|
|
4
|
+
import { ISupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
5
|
+
import { ILineAndUri } from '../../types';
|
|
6
|
+
export interface IParsedTestStep {
|
|
7
|
+
actionLocation?: ILineAndUri;
|
|
8
|
+
argument?: messages.PickleStepArgument;
|
|
9
|
+
attachments: messages.Attachment[];
|
|
10
|
+
keyword: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
result: messages.TestStepResult;
|
|
13
|
+
snippet?: string;
|
|
14
|
+
sourceLocation?: ILineAndUri;
|
|
15
|
+
text?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IParsedTestCase {
|
|
18
|
+
attempt: number;
|
|
19
|
+
name: string;
|
|
20
|
+
sourceLocation?: ILineAndUri;
|
|
21
|
+
worstTestStepResult: messages.TestStepResult;
|
|
22
|
+
}
|
|
23
|
+
export interface IParsedTestCaseAttempt {
|
|
24
|
+
testCase: IParsedTestCase;
|
|
25
|
+
testSteps: IParsedTestStep[];
|
|
26
|
+
}
|
|
27
|
+
export interface IParseTestCaseAttemptRequest {
|
|
28
|
+
testCaseAttempt: ITestCaseAttempt;
|
|
29
|
+
snippetBuilder: StepDefinitionSnippetBuilder;
|
|
30
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
31
|
+
}
|
|
32
|
+
export declare function parseTestCaseAttempt({ testCaseAttempt, snippetBuilder, supportCodeLibrary, }: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.parseTestCaseAttempt = void 0;
|
|
27
|
+
const keyword_type_1 = require("./keyword_type");
|
|
28
|
+
const gherkin_document_parser_1 = require("./gherkin_document_parser");
|
|
29
|
+
const pickle_parser_1 = require("./pickle_parser");
|
|
30
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
31
|
+
const value_checker_1 = require("../../value_checker");
|
|
32
|
+
const messages_1 = require("@cucumber/messages");
|
|
33
|
+
function parseStep({ isBeforeHook, gherkinStepMap, keyword, keywordType, pickleStep, pickleUri, snippetBuilder, supportCodeLibrary, testStep, testStepResult, testStepAttachments, }) {
|
|
34
|
+
const out = {
|
|
35
|
+
attachments: testStepAttachments,
|
|
36
|
+
keyword: (0, value_checker_1.doesHaveValue)(testStep.pickleStepId)
|
|
37
|
+
? keyword
|
|
38
|
+
: isBeforeHook
|
|
39
|
+
? 'Before'
|
|
40
|
+
: 'After',
|
|
41
|
+
result: testStepResult,
|
|
42
|
+
};
|
|
43
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.hookId)) {
|
|
44
|
+
let hookDefinition;
|
|
45
|
+
if (isBeforeHook) {
|
|
46
|
+
hookDefinition = supportCodeLibrary.beforeTestCaseHookDefinitions.find((x) => x.id === testStep.hookId);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
hookDefinition = supportCodeLibrary.afterTestCaseHookDefinitions.find((x) => x.id === testStep.hookId);
|
|
50
|
+
}
|
|
51
|
+
out.actionLocation = {
|
|
52
|
+
uri: hookDefinition.uri,
|
|
53
|
+
line: hookDefinition.line,
|
|
54
|
+
};
|
|
55
|
+
out.name = hookDefinition.name;
|
|
56
|
+
}
|
|
57
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.stepDefinitionIds) &&
|
|
58
|
+
testStep.stepDefinitionIds.length === 1) {
|
|
59
|
+
const stepDefinition = supportCodeLibrary.stepDefinitions.find((x) => x.id === testStep.stepDefinitionIds[0]);
|
|
60
|
+
out.actionLocation = {
|
|
61
|
+
uri: stepDefinition.uri,
|
|
62
|
+
line: stepDefinition.line,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
|
|
66
|
+
out.sourceLocation = {
|
|
67
|
+
uri: pickleUri,
|
|
68
|
+
line: gherkinStepMap[pickleStep.astNodeIds[0]].location.line,
|
|
69
|
+
};
|
|
70
|
+
out.text = pickleStep.text;
|
|
71
|
+
if ((0, value_checker_1.doesHaveValue)(pickleStep.argument)) {
|
|
72
|
+
out.argument = pickleStep.argument;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (testStepResult.status === messages.TestStepResultStatus.UNDEFINED) {
|
|
76
|
+
out.snippet = snippetBuilder.build({ keywordType, pickleStep });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
// Converts a testCaseAttempt into a json object with all data needed for
|
|
81
|
+
// displaying it in a pretty format
|
|
82
|
+
function parseTestCaseAttempt({ testCaseAttempt, snippetBuilder, supportCodeLibrary, }) {
|
|
83
|
+
const { testCase, pickle, gherkinDocument } = testCaseAttempt;
|
|
84
|
+
const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(gherkinDocument);
|
|
85
|
+
const gherkinScenarioLocationMap = (0, gherkin_document_parser_1.getGherkinScenarioLocationMap)(gherkinDocument);
|
|
86
|
+
const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(pickle);
|
|
87
|
+
const relativePickleUri = pickle.uri;
|
|
88
|
+
const parsedTestCase = {
|
|
89
|
+
attempt: testCaseAttempt.attempt,
|
|
90
|
+
name: pickle.name,
|
|
91
|
+
sourceLocation: {
|
|
92
|
+
uri: relativePickleUri,
|
|
93
|
+
line: gherkinScenarioLocationMap[pickle.astNodeIds[pickle.astNodeIds.length - 1]].line,
|
|
94
|
+
},
|
|
95
|
+
worstTestStepResult: testCaseAttempt.worstTestStepResult,
|
|
96
|
+
};
|
|
97
|
+
const parsedTestSteps = [];
|
|
98
|
+
let isBeforeHook = true;
|
|
99
|
+
let previousKeywordType = keyword_type_1.KeywordType.Precondition;
|
|
100
|
+
testCase.testSteps.forEach((testStep) => {
|
|
101
|
+
const testStepResult = testCaseAttempt.stepResults[testStep.id] || new messages_1.TestStepResult();
|
|
102
|
+
isBeforeHook = isBeforeHook && (0, value_checker_1.doesHaveValue)(testStep.hookId);
|
|
103
|
+
let keyword, keywordType, pickleStep;
|
|
104
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId)) {
|
|
105
|
+
pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
106
|
+
keyword = (0, pickle_parser_1.getStepKeyword)({ pickleStep, gherkinStepMap });
|
|
107
|
+
keywordType = (0, keyword_type_1.getStepKeywordType)({
|
|
108
|
+
keyword,
|
|
109
|
+
language: gherkinDocument.feature.language,
|
|
110
|
+
previousKeywordType,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const parsedStep = parseStep({
|
|
114
|
+
isBeforeHook,
|
|
115
|
+
gherkinStepMap,
|
|
116
|
+
keyword,
|
|
117
|
+
keywordType,
|
|
118
|
+
pickleStep,
|
|
119
|
+
pickleUri: relativePickleUri,
|
|
120
|
+
snippetBuilder,
|
|
121
|
+
supportCodeLibrary,
|
|
122
|
+
testStep,
|
|
123
|
+
testStepResult,
|
|
124
|
+
testStepAttachments: (0, value_checker_1.valueOrDefault)(testCaseAttempt.stepAttachments[testStep.id], []),
|
|
125
|
+
});
|
|
126
|
+
parsedTestSteps.push(parsedStep);
|
|
127
|
+
previousKeywordType = keywordType;
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
testCase: parsedTestCase,
|
|
131
|
+
testSteps: parsedTestSteps,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
exports.parseTestCaseAttempt = parseTestCaseAttempt;
|
|
135
|
+
//# sourceMappingURL=test_case_attempt_parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_case_attempt_parser.js","sourceRoot":"","sources":["../../../src/formatter/helpers/test_case_attempt_parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgE;AAChE,uEAGkC;AAClC,mDAAkE;AAClE,6DAA8C;AAI9C,uDAAmE;AAGnE,iDAAmD;AAwCnD,SAAS,SAAS,CAAC,EACjB,YAAY,EACZ,cAAc,EACd,OAAO,EACP,WAAW,EACX,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AAC,EAAE,CAAC,EAC5C,EAAE,CACH;SACF,CAAC,CAAA;QACF,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAChC,mBAAmB,GAAG,WAAW,CAAA;IACnC,CAAC,CAAC,CAAA;IACF,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,SAAS,EAAE,eAAe;KAC3B,CAAA;AACH,CAAC;AAjED,oDAiEC","sourcesContent":["import { getStepKeywordType, KeywordType } from './keyword_type'\nimport {\n getGherkinScenarioLocationMap,\n getGherkinStepMap,\n} from './gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './pickle_parser'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseAttempt } from './event_data_collector'\nimport StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue, valueOrDefault } from '../../value_checker'\nimport TestCaseHookDefinition from '../../models/test_case_hook_definition'\nimport { ILineAndUri } from '../../types'\nimport { TestStepResult } from '@cucumber/messages'\n\nexport interface IParsedTestStep {\n actionLocation?: ILineAndUri\n argument?: messages.PickleStepArgument\n attachments: messages.Attachment[]\n keyword: string\n name?: string\n result: messages.TestStepResult\n snippet?: string\n sourceLocation?: ILineAndUri\n text?: string\n}\n\nexport interface IParsedTestCase {\n attempt: number\n name: string\n sourceLocation?: ILineAndUri\n worstTestStepResult: messages.TestStepResult\n}\n\nexport interface IParsedTestCaseAttempt {\n testCase: IParsedTestCase\n testSteps: IParsedTestStep[]\n}\n\ninterface IParseStepRequest {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n keyword: string\n keywordType: KeywordType\n pickleStep: messages.PickleStep\n pickleUri: string\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n testStep: messages.TestStep\n testStepResult: messages.TestStepResult\n testStepAttachments: messages.Attachment[]\n}\n\nfunction parseStep({\n isBeforeHook,\n gherkinStepMap,\n keyword,\n keywordType,\n pickleStep,\n pickleUri,\n snippetBuilder,\n supportCodeLibrary,\n testStep,\n testStepResult,\n testStepAttachments,\n}: IParseStepRequest): IParsedTestStep {\n const out: IParsedTestStep = {\n attachments: testStepAttachments,\n keyword: doesHaveValue(testStep.pickleStepId)\n ? keyword\n : isBeforeHook\n ? 'Before'\n : 'After',\n result: testStepResult,\n }\n if (doesHaveValue(testStep.hookId)) {\n let hookDefinition: TestCaseHookDefinition\n if (isBeforeHook) {\n hookDefinition = supportCodeLibrary.beforeTestCaseHookDefinitions.find(\n (x) => x.id === testStep.hookId\n )\n } else {\n hookDefinition = supportCodeLibrary.afterTestCaseHookDefinitions.find(\n (x) => x.id === testStep.hookId\n )\n }\n out.actionLocation = {\n uri: hookDefinition.uri,\n line: hookDefinition.line,\n }\n out.name = hookDefinition.name\n }\n if (\n doesHaveValue(testStep.stepDefinitionIds) &&\n testStep.stepDefinitionIds.length === 1\n ) {\n const stepDefinition = supportCodeLibrary.stepDefinitions.find(\n (x) => x.id === testStep.stepDefinitionIds[0]\n )\n out.actionLocation = {\n uri: stepDefinition.uri,\n line: stepDefinition.line,\n }\n }\n if (doesHaveValue(testStep.pickleStepId)) {\n out.sourceLocation = {\n uri: pickleUri,\n line: gherkinStepMap[pickleStep.astNodeIds[0]].location.line,\n }\n out.text = pickleStep.text\n if (doesHaveValue(pickleStep.argument)) {\n out.argument = pickleStep.argument\n }\n }\n if (testStepResult.status === messages.TestStepResultStatus.UNDEFINED) {\n out.snippet = snippetBuilder.build({ keywordType, pickleStep })\n }\n return out\n}\n\nexport interface IParseTestCaseAttemptRequest {\n testCaseAttempt: ITestCaseAttempt\n snippetBuilder: StepDefinitionSnippetBuilder\n supportCodeLibrary: ISupportCodeLibrary\n}\n\n// Converts a testCaseAttempt into a json object with all data needed for\n// displaying it in a pretty format\nexport function parseTestCaseAttempt({\n testCaseAttempt,\n snippetBuilder,\n supportCodeLibrary,\n}: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt {\n const { testCase, pickle, gherkinDocument } = testCaseAttempt\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const gherkinScenarioLocationMap =\n getGherkinScenarioLocationMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n const relativePickleUri = pickle.uri\n const parsedTestCase: IParsedTestCase = {\n attempt: testCaseAttempt.attempt,\n name: pickle.name,\n sourceLocation: {\n uri: relativePickleUri,\n line: gherkinScenarioLocationMap[\n pickle.astNodeIds[pickle.astNodeIds.length - 1]\n ].line,\n },\n worstTestStepResult: testCaseAttempt.worstTestStepResult,\n }\n const parsedTestSteps: IParsedTestStep[] = []\n let isBeforeHook = true\n let previousKeywordType = KeywordType.Precondition\n\n testCase.testSteps.forEach((testStep) => {\n const testStepResult =\n testCaseAttempt.stepResults[testStep.id] || new TestStepResult()\n\n isBeforeHook = isBeforeHook && doesHaveValue(testStep.hookId)\n\n let keyword, keywordType, pickleStep\n if (doesHaveValue(testStep.pickleStepId)) {\n pickleStep = pickleStepMap[testStep.pickleStepId]\n keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n keywordType = getStepKeywordType({\n keyword,\n language: gherkinDocument.feature.language,\n previousKeywordType,\n })\n }\n const parsedStep = parseStep({\n isBeforeHook,\n gherkinStepMap,\n keyword,\n keywordType,\n pickleStep,\n pickleUri: relativePickleUri,\n snippetBuilder,\n supportCodeLibrary,\n testStep,\n testStepResult,\n testStepAttachments: valueOrDefault(\n testCaseAttempt.stepAttachments[testStep.id],\n []\n ),\n })\n parsedTestSteps.push(parsedStep)\n previousKeywordType = keywordType\n })\n return {\n testCase: parsedTestCase,\n testSteps: parsedTestSteps,\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
|
+
import StepDefinition from '../../../models/step_definition';
|
|
3
|
+
import EventDataCollector from '../event_data_collector';
|
|
4
|
+
export interface IUsageMatch {
|
|
5
|
+
duration?: messages.Duration;
|
|
6
|
+
line: number;
|
|
7
|
+
text: string;
|
|
8
|
+
uri: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IUsage {
|
|
11
|
+
code: string;
|
|
12
|
+
line: number;
|
|
13
|
+
matches: IUsageMatch[];
|
|
14
|
+
meanDuration?: messages.Duration;
|
|
15
|
+
pattern: string;
|
|
16
|
+
patternType: string;
|
|
17
|
+
uri: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IGetUsageRequest {
|
|
20
|
+
eventDataCollector: EventDataCollector;
|
|
21
|
+
stepDefinitions: StepDefinition[];
|
|
22
|
+
}
|
|
23
|
+
export declare function getUsage({ stepDefinitions, eventDataCollector, }: IGetUsageRequest): IUsage[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getUsage = void 0;
|
|
27
|
+
const pickle_parser_1 = require("../pickle_parser");
|
|
28
|
+
const gherkin_document_parser_1 = require("../gherkin_document_parser");
|
|
29
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
30
|
+
const value_checker_1 = require("../../../value_checker");
|
|
31
|
+
function buildEmptyMapping(stepDefinitions) {
|
|
32
|
+
const mapping = {};
|
|
33
|
+
stepDefinitions.forEach((stepDefinition) => {
|
|
34
|
+
mapping[stepDefinition.id] = {
|
|
35
|
+
code: stepDefinition.unwrappedCode.toString(),
|
|
36
|
+
line: stepDefinition.line,
|
|
37
|
+
pattern: stepDefinition.expression.source,
|
|
38
|
+
patternType: stepDefinition.expression.constructor.name,
|
|
39
|
+
matches: [],
|
|
40
|
+
uri: stepDefinition.uri,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
return mapping;
|
|
44
|
+
}
|
|
45
|
+
const unexecutedStatuses = [
|
|
46
|
+
messages.TestStepResultStatus.AMBIGUOUS,
|
|
47
|
+
messages.TestStepResultStatus.SKIPPED,
|
|
48
|
+
messages.TestStepResultStatus.UNDEFINED,
|
|
49
|
+
];
|
|
50
|
+
function buildMapping({ stepDefinitions, eventDataCollector, }) {
|
|
51
|
+
const mapping = buildEmptyMapping(stepDefinitions);
|
|
52
|
+
eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {
|
|
53
|
+
const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(testCaseAttempt.pickle);
|
|
54
|
+
const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(testCaseAttempt.gherkinDocument);
|
|
55
|
+
testCaseAttempt.testCase.testSteps.forEach((testStep) => {
|
|
56
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.pickleStepId) &&
|
|
57
|
+
testStep.stepDefinitionIds.length === 1) {
|
|
58
|
+
const stepDefinitionId = testStep.stepDefinitionIds[0];
|
|
59
|
+
const pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
60
|
+
const gherkinStep = gherkinStepMap[pickleStep.astNodeIds[0]];
|
|
61
|
+
const match = {
|
|
62
|
+
line: gherkinStep.location.line,
|
|
63
|
+
text: pickleStep.text,
|
|
64
|
+
uri: testCaseAttempt.pickle.uri,
|
|
65
|
+
};
|
|
66
|
+
const { duration, status } = testCaseAttempt.stepResults[testStep.id];
|
|
67
|
+
if (!unexecutedStatuses.includes(status) && (0, value_checker_1.doesHaveValue)(duration)) {
|
|
68
|
+
match.duration = duration;
|
|
69
|
+
}
|
|
70
|
+
if ((0, value_checker_1.doesHaveValue)(mapping[stepDefinitionId])) {
|
|
71
|
+
mapping[stepDefinitionId].matches.push(match);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return mapping;
|
|
77
|
+
}
|
|
78
|
+
function normalizeDuration(duration) {
|
|
79
|
+
if (duration == null) {
|
|
80
|
+
return Number.MIN_SAFE_INTEGER;
|
|
81
|
+
}
|
|
82
|
+
return messages.TimeConversion.durationToMilliseconds(duration);
|
|
83
|
+
}
|
|
84
|
+
function buildResult(mapping) {
|
|
85
|
+
return Object.keys(mapping)
|
|
86
|
+
.map((stepDefinitionId) => {
|
|
87
|
+
const { matches, ...rest } = mapping[stepDefinitionId];
|
|
88
|
+
const sortedMatches = matches.sort((a, b) => {
|
|
89
|
+
if (a.duration === b.duration) {
|
|
90
|
+
return a.text < b.text ? -1 : 1;
|
|
91
|
+
}
|
|
92
|
+
return normalizeDuration(b.duration) - normalizeDuration(a.duration);
|
|
93
|
+
});
|
|
94
|
+
const result = { matches: sortedMatches, ...rest };
|
|
95
|
+
const durations = matches
|
|
96
|
+
.filter((m) => m.duration != null)
|
|
97
|
+
.map((m) => m.duration);
|
|
98
|
+
if (durations.length > 0) {
|
|
99
|
+
const totalMilliseconds = durations.reduce((acc, x) => acc + messages.TimeConversion.durationToMilliseconds(x), 0);
|
|
100
|
+
result.meanDuration = messages.TimeConversion.millisecondsToDuration(totalMilliseconds / durations.length);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
})
|
|
104
|
+
.sort((a, b) => normalizeDuration(b.meanDuration) - normalizeDuration(a.meanDuration));
|
|
105
|
+
}
|
|
106
|
+
function getUsage({ stepDefinitions, eventDataCollector, }) {
|
|
107
|
+
const mapping = buildMapping({ stepDefinitions, eventDataCollector });
|
|
108
|
+
return buildResult(mapping);
|
|
109
|
+
}
|
|
110
|
+
exports.getUsage = getUsage;
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/formatter/helpers/usage_helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAmD;AACnD,wEAA8D;AAC9D,6DAA8C;AAE9C,0DAAsD;AAyBtD,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,CAA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AI,IAAI,CAAC;aACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QACzB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,MAAM,iBAAiB,GAAG,SAAS,CAAC,MAAM,CACxC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,EACnE,CAAC,CACF,CAAA;YACD,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAClE,iBAAiB,GAAG,SAAS,CAAC,MAAM,CACrC,CAAA;SACF;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAC;SACD,IAAI,CACH,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CACvB,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,CACxE,CAAA;AACL,CAAC;AAED,SAAgB,QAAQ,CAAC,EACvB,eAAe,EACf,kBAAkB,GACD;IACjB,MAAM,OAAO,GAAG,YAAY,CAAC,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC,CAAA;IACrE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAA;AAC7B,CAAC;AAND,4BAMC","sourcesContent":["import { 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 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 stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): Record<string, IUsage> {\n const mapping = buildEmptyMapping(stepDefinitions)\n eventDataCollector.getTestCaseAttempts().forEach((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 normalizeDuration(duration?: messages.Duration): number {\n if (duration == null) {\n return Number.MIN_SAFE_INTEGER\n }\n return messages.TimeConversion.durationToMilliseconds(duration)\n}\n\nfunction buildResult(mapping: Record<string, IUsage>): IUsage[] {\n return Object.keys(mapping)\n .map((stepDefinitionId) => {\n const { matches, ...rest } = mapping[stepDefinitionId]\n const sortedMatches = matches.sort((a: IUsageMatch, b: IUsageMatch) => {\n if (a.duration === b.duration) {\n return a.text < b.text ? -1 : 1\n }\n return normalizeDuration(b.duration) - normalizeDuration(a.duration)\n })\n const result = { matches: sortedMatches, ...rest }\n const durations: messages.Duration[] = matches\n .filter((m) => m.duration != null)\n .map((m) => m.duration)\n if (durations.length > 0) {\n const totalMilliseconds = durations.reduce(\n (acc, x) => acc + messages.TimeConversion.durationToMilliseconds(x),\n 0\n )\n result.meanDuration = messages.TimeConversion.millisecondsToDuration(\n totalMilliseconds / durations.length\n )\n }\n return result\n })\n .sort(\n (a: IUsage, b: IUsage) =>\n normalizeDuration(b.meanDuration) - normalizeDuration(a.meanDuration)\n )\n}\n\nexport function getUsage({\n stepDefinitions,\n eventDataCollector,\n}: IGetUsageRequest): IUsage[] {\n const mapping = buildMapping({ stepDefinitions, eventDataCollector })\n return buildResult(mapping)\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
7
|
+
const resolve_pkg_1 = __importDefault(require("resolve-pkg"));
|
|
8
|
+
const html_formatter_1 = __importDefault(require("@cucumber/html-formatter"));
|
|
9
|
+
const stream_1 = require("stream");
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
class HtmlFormatter extends _1.default {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
this._htmlStream = new html_formatter_1.default((0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
15
|
+
'/dist/main.css', (0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
16
|
+
'/dist/main.js');
|
|
17
|
+
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
18
|
+
this._htmlStream.write(envelope);
|
|
19
|
+
});
|
|
20
|
+
this._htmlStream.on('data', (chunk) => this.log(chunk));
|
|
21
|
+
}
|
|
22
|
+
async finished() {
|
|
23
|
+
this._htmlStream.end();
|
|
24
|
+
await (0, util_1.promisify)(stream_1.finished)(this._htmlStream);
|
|
25
|
+
await super.finished();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = HtmlFormatter;
|
|
29
|
+
HtmlFormatter.documentation = 'Outputs HTML report';
|
|
30
|
+
//# sourceMappingURL=html_formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html_formatter.js","sourceRoot":"","sources":["../../src/formatter/html_formatter.ts"],"names":[],"mappings":";;;;;AAAA,yCAAgD;AAEhD,8DAAoC;AACpC,8EAAyD;AACzD,mCAAiC;AACjC,+BAAgC;AAEhC,MAAqB,aAAc,SAAQ,UAAS;IAIlD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAkB,CACvC,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,IAAA,qBAAU,EAAC,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,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,IAAA,gBAAS,EAAC,iBAAQ,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC3C,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;;AAtBH,gCAuBC;AArBwB,2BAAa,GAAW,qBAAqB,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from '.'\nimport * as messages from '@cucumber/messages'\nimport resolvePkg from 'resolve-pkg'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport { finished } from 'stream'\nimport { promisify } from 'util'\n\nexport default class HtmlFormatter extends Formatter {\n private readonly _htmlStream: CucumberHtmlStream\n public static readonly documentation: string = 'Outputs HTML report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this._htmlStream = 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 this._htmlStream.write(envelope)\n })\n this._htmlStream.on('data', (chunk) => this.log(chunk))\n }\n\n async finished(): Promise<void> {\n this._htmlStream.end()\n await promisify(finished)(this._htmlStream)\n await super.finished()\n }\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IColorFns } from './get_color_fns';
|
|
4
|
+
import { EventDataCollector } from './helpers';
|
|
5
|
+
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
|
+
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
|
|
10
|
+
export interface FormatRerunOptions {
|
|
11
|
+
separator?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FormatOptions {
|
|
14
|
+
colorsEnabled?: boolean;
|
|
15
|
+
rerun?: FormatRerunOptions;
|
|
16
|
+
snippetInterface?: SnippetInterface;
|
|
17
|
+
snippetSyntax?: string;
|
|
18
|
+
printAttachments?: boolean;
|
|
19
|
+
[customKey: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface IPublishConfig {
|
|
22
|
+
url: string;
|
|
23
|
+
token: string;
|
|
24
|
+
}
|
|
25
|
+
export type IFormatterStream = Writable;
|
|
26
|
+
export type IFormatterLogFn = (buffer: string | Uint8Array) => void;
|
|
27
|
+
export type IFormatterCleanupFn = () => Promise<any>;
|
|
28
|
+
export interface IFormatterOptions {
|
|
29
|
+
colorFns: IColorFns;
|
|
30
|
+
cwd: string;
|
|
31
|
+
eventBroadcaster: EventEmitter;
|
|
32
|
+
eventDataCollector: EventDataCollector;
|
|
33
|
+
log: IFormatterLogFn;
|
|
34
|
+
parsedArgvOptions: FormatOptions;
|
|
35
|
+
snippetBuilder: StepDefinitionSnippetBuilder;
|
|
36
|
+
stream: Writable;
|
|
37
|
+
cleanup: IFormatterCleanupFn;
|
|
38
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
39
|
+
}
|
|
40
|
+
export default class Formatter {
|
|
41
|
+
protected colorFns: IColorFns;
|
|
42
|
+
protected cwd: string;
|
|
43
|
+
protected eventDataCollector: EventDataCollector;
|
|
44
|
+
protected log: IFormatterLogFn;
|
|
45
|
+
protected snippetBuilder: StepDefinitionSnippetBuilder;
|
|
46
|
+
protected stream: Writable;
|
|
47
|
+
protected supportCodeLibrary: ISupportCodeLibrary;
|
|
48
|
+
protected printAttachments: boolean;
|
|
49
|
+
private readonly cleanup;
|
|
50
|
+
static readonly documentation: string;
|
|
51
|
+
constructor(options: IFormatterOptions);
|
|
52
|
+
finished(): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const value_checker_1 = require("../value_checker");
|
|
4
|
+
class Formatter {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.colorFns = options.colorFns;
|
|
7
|
+
this.cwd = options.cwd;
|
|
8
|
+
this.eventDataCollector = options.eventDataCollector;
|
|
9
|
+
this.log = options.log;
|
|
10
|
+
this.snippetBuilder = options.snippetBuilder;
|
|
11
|
+
this.stream = options.stream;
|
|
12
|
+
this.supportCodeLibrary = options.supportCodeLibrary;
|
|
13
|
+
this.cleanup = options.cleanup;
|
|
14
|
+
this.printAttachments = (0, value_checker_1.valueOrDefault)(options.parsedArgvOptions.printAttachments, true);
|
|
15
|
+
}
|
|
16
|
+
async finished() {
|
|
17
|
+
await this.cleanup();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = Formatter;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAMA,oDAAiD;AAsCjD,MAAqB,SAAS;IAY5B,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 { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { Writable } from 'stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { EventEmitter } from 'events'\nimport { valueOrDefault } from '../value_checker'\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"]}
|