@dev-blinq/cucumber-js 1.0.0-amdocs
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 +68 -0
- package/api/index.d.ts +6 -0
- package/bin/cucumber-js +3 -0
- package/bin/cucumber.js +3 -0
- package/bin/cucumber.ts +2 -0
- package/bin/download-install.js +167 -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 +66 -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 +146 -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 +177 -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 +39 -0
- package/lib/cli/helpers.js +224 -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 +64 -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 +104 -0
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/axios_client.d.ts +1 -0
- package/lib/configuration/axios_client.js +40 -0
- package/lib/configuration/axios_client.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 +29 -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 +30 -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/api.d.ts +2 -0
- package/lib/formatter/api.js +53 -0
- package/lib/formatter/api.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/bvt_analysis_formatter.d.ts +30 -0
- package/lib/formatter/bvt_analysis_formatter.js +334 -0
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -0
- package/lib/formatter/feature_data_format.d.ts +23 -0
- package/lib/formatter/feature_data_format.js +182 -0
- package/lib/formatter/feature_data_format.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/constants.d.ts +44 -0
- package/lib/formatter/helpers/constants.js +50 -0
- package/lib/formatter/helpers/constants.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 +45 -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/report_generator.d.ts +148 -0
- package/lib/formatter/helpers/report_generator.js +573 -0
- package/lib/formatter/helpers/report_generator.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/upload_serivce.d.ts +26 -0
- package/lib/formatter/helpers/upload_serivce.js +237 -0
- package/lib/formatter/helpers/upload_serivce.js.map +1 -0
- package/lib/formatter/helpers/uploader.d.ts +12 -0
- package/lib/formatter/helpers/uploader.js +151 -0
- package/lib/formatter/helpers/uploader.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 +55 -0
- package/lib/runtime/test_case_runner.js +277 -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 +197 -0
|
@@ -0,0 +1,112 @@
|
|
|
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 stream_1 = require("stream");
|
|
7
|
+
const tmp_1 = __importDefault(require("tmp"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const http_1 = __importDefault(require("http"));
|
|
10
|
+
const https_1 = __importDefault(require("https"));
|
|
11
|
+
const value_checker_1 = require("../value_checker");
|
|
12
|
+
/**
|
|
13
|
+
* This Writable writes data to a HTTP/HTTPS URL.
|
|
14
|
+
*
|
|
15
|
+
* It has special handling for https://reports.cucumber.io/
|
|
16
|
+
* which uses an API where the first request is a `GET`,
|
|
17
|
+
* and if the response is 202 with a Location header, issues
|
|
18
|
+
* a PUT request to that URL.
|
|
19
|
+
*
|
|
20
|
+
* 3xx redirects are not currently followed.
|
|
21
|
+
*/
|
|
22
|
+
class HttpStream extends stream_1.Transform {
|
|
23
|
+
constructor(url, method, headers) {
|
|
24
|
+
super({
|
|
25
|
+
readableObjectMode: true,
|
|
26
|
+
});
|
|
27
|
+
this.url = url;
|
|
28
|
+
this.method = method;
|
|
29
|
+
this.headers = headers;
|
|
30
|
+
}
|
|
31
|
+
_write(chunk, encoding, callback) {
|
|
32
|
+
if (this.tempFile === undefined) {
|
|
33
|
+
tmp_1.default.file((err, name, fd) => {
|
|
34
|
+
if ((0, value_checker_1.doesHaveValue)(err))
|
|
35
|
+
return callback(err);
|
|
36
|
+
this.tempFilePath = name;
|
|
37
|
+
this.tempFile = fs_1.default.createWriteStream(name, { fd });
|
|
38
|
+
this.tempFile.write(chunk, encoding, callback);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.tempFile.write(chunk, encoding, callback);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_final(callback) {
|
|
46
|
+
this.tempFile.end(() => {
|
|
47
|
+
this.sendHttpRequest(this.url, this.method, this.headers, (err1, res1) => {
|
|
48
|
+
if ((0, value_checker_1.doesHaveValue)(err1))
|
|
49
|
+
return callback(err1);
|
|
50
|
+
this.pushResponseBody(res1, () => {
|
|
51
|
+
this.emitErrorUnlessHttp2xx(res1, this.url, this.method);
|
|
52
|
+
if (res1.statusCode === 202 &&
|
|
53
|
+
res1.headers.location !== undefined) {
|
|
54
|
+
this.sendHttpRequest(res1.headers.location, 'PUT', {}, (err2, res2) => {
|
|
55
|
+
if ((0, value_checker_1.doesHaveValue)(err2))
|
|
56
|
+
return callback(err2);
|
|
57
|
+
this.emitErrorUnlessHttp2xx(res2, this.url, this.method);
|
|
58
|
+
callback();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
callback();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
pushResponseBody(res, done) {
|
|
69
|
+
let body = Buffer.alloc(0);
|
|
70
|
+
res.on('data', (chunk) => {
|
|
71
|
+
body = Buffer.concat([body, chunk]);
|
|
72
|
+
});
|
|
73
|
+
res.on('end', () => {
|
|
74
|
+
this.push(body.toString('utf-8'));
|
|
75
|
+
done();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
emitErrorUnlessHttp2xx(res, url, method) {
|
|
79
|
+
if (res.statusCode >= 300)
|
|
80
|
+
this.emit('error', new Error(`Unexpected http status ${res.statusCode} from ${method} ${url}`));
|
|
81
|
+
}
|
|
82
|
+
sendHttpRequest(url, method, headers, callback) {
|
|
83
|
+
const httpx = (0, value_checker_1.doesHaveValue)(url.match(/^https:/)) ? https_1.default : http_1.default;
|
|
84
|
+
const additionalHttpHeaders = {};
|
|
85
|
+
const upload = method === 'PUT' || method === 'POST';
|
|
86
|
+
if (upload) {
|
|
87
|
+
additionalHttpHeaders['Content-Length'] = fs_1.default.statSync(this.tempFilePath).size;
|
|
88
|
+
}
|
|
89
|
+
const allHeaders = { ...headers, ...additionalHttpHeaders };
|
|
90
|
+
const req = httpx.request(url, {
|
|
91
|
+
method,
|
|
92
|
+
headers: allHeaders,
|
|
93
|
+
});
|
|
94
|
+
req.on('error', (err) => this.emit('error', err));
|
|
95
|
+
req.on('response', (res) => {
|
|
96
|
+
res.on('error', (err) => this.emit('error', err));
|
|
97
|
+
callback(null, res);
|
|
98
|
+
});
|
|
99
|
+
if (upload) {
|
|
100
|
+
(0, stream_1.pipeline)(fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
|
|
101
|
+
if ((0, value_checker_1.doesHaveValue)(err)) {
|
|
102
|
+
this.emit('error', err);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
req.end();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.default = HttpStream;
|
|
112
|
+
//# sourceMappingURL=http_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/publish/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsD;AACtD,8CAAqB;AACrB,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,kBAAS;IAI/C,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC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AG,CAAC,GAAG,EAAE,CAAA;SACV;IACH,CAAC;CACF;AA9HD,6BA8HC","sourcesContent":["import { pipeline, Transform, Writable } from 'stream'\nimport tmp from 'tmp'\nimport fs from 'fs'\nimport http from 'http'\nimport https from 'https'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(res2, this.url, this.method)\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/publish/index.ts"],"names":[],"mappings":";;AAAA,qDAAgD;AAEhD,kBAAe,8BAAa,CAAA","sourcesContent":["import { publishPlugin } from './publish_plugin'\n\nexport default publishPlugin\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.publishPlugin = void 0;
|
|
7
|
+
const http_stream_1 = __importDefault(require("./http_stream"));
|
|
8
|
+
const stream_1 = require("stream");
|
|
9
|
+
const supports_color_1 = require("supports-color");
|
|
10
|
+
const has_ansi_1 = __importDefault(require("has-ansi"));
|
|
11
|
+
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
12
|
+
const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
|
|
13
|
+
const publishPlugin = async ({ on, logger, configuration, environment, }) => {
|
|
14
|
+
if (!configuration.formats.publish) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = configuration.formats.publish;
|
|
18
|
+
const headers = {};
|
|
19
|
+
if (token !== undefined) {
|
|
20
|
+
headers.Authorization = `Bearer ${token}`;
|
|
21
|
+
}
|
|
22
|
+
const stream = new http_stream_1.default(url, 'GET', headers);
|
|
23
|
+
const readerStream = new stream_1.Writable({
|
|
24
|
+
objectMode: true,
|
|
25
|
+
write: function (responseBody, encoding, writeCallback) {
|
|
26
|
+
environment.stderr.write(sanitisePublishOutput(responseBody, environment.stderr) + '\n');
|
|
27
|
+
writeCallback();
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
stream.pipe(readerStream);
|
|
31
|
+
stream.on('error', (error) => logger.error(error.message));
|
|
32
|
+
on('message', (value) => stream.write(JSON.stringify(value) + '\n'));
|
|
33
|
+
return () => stream.end();
|
|
34
|
+
};
|
|
35
|
+
exports.publishPlugin = publishPlugin;
|
|
36
|
+
/*
|
|
37
|
+
This is because the Cucumber Reports service returns a pre-formatted console message
|
|
38
|
+
including ANSI escapes, so if our stderr stream doesn't support those we need to
|
|
39
|
+
strip them back out. Ideally we should get structured data from the service and
|
|
40
|
+
compose the console message on this end.
|
|
41
|
+
*/
|
|
42
|
+
function sanitisePublishOutput(raw, stderr) {
|
|
43
|
+
if (!(0, supports_color_1.supportsColor)(stderr) && (0, has_ansi_1.default)(raw)) {
|
|
44
|
+
return (0, strip_ansi_1.default)(raw);
|
|
45
|
+
}
|
|
46
|
+
return raw;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=publish_plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AACA,gEAAsC;AACtC,mCAAiC;AACjC,mDAA8C;AAC9C,wDAA8B;AAC9B,4DAAkC;AAElC,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAExE,MAAM,aAAa,GAAW,KAAK,EAAE,EAC1C,EAAE,EACF,MAAM,EACN,aAAa,EACb,WAAW,GACZ,EAAE,EAAE;IACH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE;QAClC,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,EAAE,GAAG,GAAG,4BAA4B,EAAE,KAAK,EAAE,GACjD,aAAa,CAAC,OAAO,CAAC,OAAO,CAAA;IAC/B,MAAM,OAAO,GAA8B,EAAE,CAAA;IAC7C,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;KAC1C;IACD,MAAM,MAAM,GAAG,IAAI,qBAAU,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IAClD,MAAM,YAAY,GAAG,IAAI,iBAAQ,CAAC;QAChC,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,UAAU,YAAoB,EAAE,QAAQ,EAAE,aAAa;YAC5D,WAAW,CAAC,MAAM,CAAC,KAAK,CACtB,qBAAqB,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAC/D,CAAA;YACD,aAAa,EAAE,CAAA;QACjB,CAAC;KACF,CAAC,CAAA;IACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IACjE,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACpE,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;AAC3B,CAAC,CAAA;AA7BY,QAAA,aAAa,iBA6BzB;AACD;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAAgB;IAC1D,IAAI,CAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAA;KACtB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { Plugin } from '../plugin'\nimport HttpStream from './http_stream'\nimport { Writable } from 'stream'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport stripAnsi from 'strip-ansi'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: Plugin = async ({\n on,\n logger,\n configuration,\n environment,\n}) => {\n if (!configuration.formats.publish) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } =\n configuration.formats.publish\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n environment.stderr.write(\n sanitisePublishOutput(responseBody, environment.stderr) + '\\n'\n )\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n stream.on('error', (error: Error) => logger.error(error.message))\n on('message', (value) => stream.write(JSON.stringify(value) + '\\n'))\n return () => stream.end()\n}\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripAnsi(raw)\n }\n return raw\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import * as messages from '@cucumber/messages';
|
|
4
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
5
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
|
+
export declare type IAssembledTestCases = Record<string, messages.TestCase>;
|
|
7
|
+
export interface IAssembleTestCasesOptions {
|
|
8
|
+
eventBroadcaster: EventEmitter;
|
|
9
|
+
newId: IdGenerator.NewId;
|
|
10
|
+
pickles: messages.Pickle[];
|
|
11
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
12
|
+
}
|
|
13
|
+
export declare function assembleTestCases({ eventBroadcaster, newId, pickles, supportCodeLibrary, }: IAssembleTestCasesOptions): Promise<IAssembledTestCases>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assembleTestCases = void 0;
|
|
4
|
+
const value_checker_1 = require("../value_checker");
|
|
5
|
+
async function assembleTestCases({ eventBroadcaster, newId, pickles, supportCodeLibrary, }) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const pickle of pickles) {
|
|
8
|
+
const { id: pickleId } = pickle;
|
|
9
|
+
const testCaseId = newId();
|
|
10
|
+
const fromBeforeHooks = makeBeforeHookSteps({
|
|
11
|
+
supportCodeLibrary,
|
|
12
|
+
pickle,
|
|
13
|
+
newId,
|
|
14
|
+
});
|
|
15
|
+
const fromStepDefinitions = makeSteps({
|
|
16
|
+
pickle,
|
|
17
|
+
supportCodeLibrary,
|
|
18
|
+
newId,
|
|
19
|
+
});
|
|
20
|
+
const fromAfterHooks = makeAfterHookSteps({
|
|
21
|
+
supportCodeLibrary,
|
|
22
|
+
pickle,
|
|
23
|
+
newId,
|
|
24
|
+
});
|
|
25
|
+
const testCase = {
|
|
26
|
+
pickleId,
|
|
27
|
+
id: testCaseId,
|
|
28
|
+
testSteps: [
|
|
29
|
+
...fromBeforeHooks,
|
|
30
|
+
...fromStepDefinitions,
|
|
31
|
+
...fromAfterHooks,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
eventBroadcaster.emit('envelope', { testCase });
|
|
35
|
+
result[pickleId] = testCase;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
exports.assembleTestCases = assembleTestCases;
|
|
40
|
+
function makeAfterHookSteps({ supportCodeLibrary, pickle, newId, }) {
|
|
41
|
+
return supportCodeLibrary.afterTestCaseHookDefinitions
|
|
42
|
+
.slice(0)
|
|
43
|
+
.reverse()
|
|
44
|
+
.filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))
|
|
45
|
+
.map((hookDefinition) => ({
|
|
46
|
+
id: newId(),
|
|
47
|
+
hookId: hookDefinition.id,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function makeBeforeHookSteps({ supportCodeLibrary, pickle, newId, }) {
|
|
51
|
+
return supportCodeLibrary.beforeTestCaseHookDefinitions
|
|
52
|
+
.filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))
|
|
53
|
+
.map((hookDefinition) => ({
|
|
54
|
+
id: newId(),
|
|
55
|
+
hookId: hookDefinition.id,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
function makeSteps({ pickle, supportCodeLibrary, newId, }) {
|
|
59
|
+
return pickle.steps.map((pickleStep) => {
|
|
60
|
+
const stepDefinitions = supportCodeLibrary.stepDefinitions.filter((stepDefinition) => stepDefinition.matchesStepName(pickleStep.text));
|
|
61
|
+
return {
|
|
62
|
+
id: newId(),
|
|
63
|
+
pickleStepId: pickleStep.id,
|
|
64
|
+
stepDefinitionIds: stepDefinitions.map((stepDefinition) => stepDefinition.id),
|
|
65
|
+
stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {
|
|
66
|
+
const result = stepDefinition.expression.match(pickleStep.text);
|
|
67
|
+
return {
|
|
68
|
+
stepMatchArguments: result.map((arg) => {
|
|
69
|
+
return {
|
|
70
|
+
group: mapArgumentGroup(arg.group),
|
|
71
|
+
parameterTypeName: arg.parameterType.name,
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
};
|
|
75
|
+
}),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function mapArgumentGroup(group) {
|
|
80
|
+
return {
|
|
81
|
+
start: group.start,
|
|
82
|
+
value: group.value,
|
|
83
|
+
children: (0, value_checker_1.doesHaveValue)(group.children)
|
|
84
|
+
? group.children.map((child) => mapArgumentGroup(child))
|
|
85
|
+
: undefined,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=assemble_test_cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble_test_cases.js","sourceRoot":"","sources":["../../src/runtime/assemble_test_cases.ts"],"names":[],"mappings":";;;AAKA,oDAAgD;AAWzC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,GACQ;IAC1B,MAAM,MAAM,GAAwB,EAAE,CAAA;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;QAC/B,MAAM,UAAU,GAAG,KAAK,EAAE,CAAA;QAC1B,MAAM,eAAe,GAAwB,mBAAmB,CAAC;YAC/D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,mBAAmB,GAAwB,SAAS,CAAC;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C;YACxD,CAAC,CAAC,SAAS;KACd,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { doesHaveValue } from '../value_checker'\n\nexport declare type IAssembledTestCases = Record<string, messages.TestCase>\n\nexport interface IAssembleTestCasesOptions {\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n pickles: messages.Pickle[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport async function assembleTestCases({\n eventBroadcaster,\n newId,\n pickles,\n supportCodeLibrary,\n}: IAssembleTestCasesOptions): Promise<IAssembledTestCases> {\n const result: IAssembledTestCases = {}\n for (const pickle of pickles) {\n const { id: pickleId } = pickle\n const testCaseId = newId()\n const fromBeforeHooks: messages.TestStep[] = makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const fromStepDefinitions: messages.TestStep[] = makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n })\n const fromAfterHooks: messages.TestStep[] = makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const testCase: messages.TestCase = {\n pickleId,\n id: testCaseId,\n testSteps: [\n ...fromBeforeHooks,\n ...fromStepDefinitions,\n ...fromAfterHooks,\n ],\n }\n eventBroadcaster.emit('envelope', { testCase })\n result[pickleId] = testCase\n }\n return result\n}\n\nfunction makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.afterTestCaseHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: ISupportCodeLibrary\n pickle: messages.Pickle\n newId: IdGenerator.NewId\n}): messages.TestStep[] {\n return supportCodeLibrary.beforeTestCaseHookDefinitions\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n}: {\n pickle: messages.Pickle\n supportCodeLibrary: ISupportCodeLibrary\n newId: () => string\n}): messages.TestStep[] {\n return pickle.steps.map((pickleStep) => {\n const stepDefinitions = supportCodeLibrary.stepDefinitions.filter(\n (stepDefinition) => stepDefinition.matchesStepName(pickleStep.text)\n )\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n stepDefinitionIds: stepDefinitions.map(\n (stepDefinition) => stepDefinition.id\n ),\n stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {\n const result = stepDefinition.expression.match(pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n })\n}\n\nfunction mapArgumentGroup(group: Group): messages.Group {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => mapArgumentGroup(child))\n : undefined,\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import * as messages from '@cucumber/messages';
|
|
5
|
+
export interface IAttachmentMedia {
|
|
6
|
+
encoding: messages.AttachmentContentEncoding;
|
|
7
|
+
contentType: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IAttachment {
|
|
10
|
+
data: string;
|
|
11
|
+
media: IAttachmentMedia;
|
|
12
|
+
fileName?: string;
|
|
13
|
+
}
|
|
14
|
+
export type IAttachFunction = (attachment: IAttachment) => void;
|
|
15
|
+
export interface ICreateAttachmentOptions {
|
|
16
|
+
mediaType: string;
|
|
17
|
+
fileName?: string;
|
|
18
|
+
}
|
|
19
|
+
export type ICreateStringAttachment = (data: string, mediaTypeOrOptions?: string | ICreateAttachmentOptions) => void;
|
|
20
|
+
export type ICreateBufferAttachment = (data: Buffer, mediaTypeOrOptions: string | ICreateAttachmentOptions) => void;
|
|
21
|
+
export type ICreateStreamAttachment = (data: Readable, mediaTypeOrOptions: string | ICreateAttachmentOptions) => Promise<void>;
|
|
22
|
+
export type ICreateStreamAttachmentWithCallback = (data: Readable, mediaTypeOrOptions: string | ICreateAttachmentOptions, callback: () => void) => void;
|
|
23
|
+
export type ICreateAttachment = ICreateStringAttachment & ICreateBufferAttachment & ICreateStreamAttachment & ICreateStreamAttachmentWithCallback;
|
|
24
|
+
export type ICreateLog = (text: string) => void;
|
|
25
|
+
export default class AttachmentManager {
|
|
26
|
+
private readonly onAttachment;
|
|
27
|
+
constructor(onAttachment: IAttachFunction);
|
|
28
|
+
log(text: string): void | Promise<void>;
|
|
29
|
+
create(data: Buffer | Readable | string, mediaTypeOrOptions?: string | ICreateAttachmentOptions, callback?: () => void): void | Promise<void>;
|
|
30
|
+
createBufferAttachment(data: Buffer, mediaType: string, fileName?: string): void;
|
|
31
|
+
createStreamAttachment(data: Readable, mediaType: string, fileName?: string, callback?: () => void): void | Promise<void>;
|
|
32
|
+
createStringAttachment(data: string, media: IAttachmentMedia, fileName?: string): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
const is_stream_1 = __importDefault(require("is-stream"));
|
|
30
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
31
|
+
const value_checker_1 = require("../../value_checker");
|
|
32
|
+
class AttachmentManager {
|
|
33
|
+
constructor(onAttachment) {
|
|
34
|
+
this.onAttachment = onAttachment;
|
|
35
|
+
}
|
|
36
|
+
log(text) {
|
|
37
|
+
return this.create(text, 'text/x.cucumber.log+plain');
|
|
38
|
+
}
|
|
39
|
+
create(data, mediaTypeOrOptions, callback) {
|
|
40
|
+
const options = normaliseOptions(mediaTypeOrOptions);
|
|
41
|
+
if (Buffer.isBuffer(data)) {
|
|
42
|
+
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
|
|
43
|
+
throw Error('Buffer attachments must specify a media type');
|
|
44
|
+
}
|
|
45
|
+
this.createBufferAttachment(data, options.mediaType, options.fileName);
|
|
46
|
+
}
|
|
47
|
+
else if (is_stream_1.default.readable(data)) {
|
|
48
|
+
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
|
|
49
|
+
throw Error('Stream attachments must specify a media type');
|
|
50
|
+
}
|
|
51
|
+
return this.createStreamAttachment(data, options.mediaType, options.fileName, callback);
|
|
52
|
+
}
|
|
53
|
+
else if (typeof data === 'string') {
|
|
54
|
+
if ((0, value_checker_1.doesNotHaveValue)(options.mediaType)) {
|
|
55
|
+
options.mediaType = 'text/plain';
|
|
56
|
+
}
|
|
57
|
+
if (options.mediaType.startsWith('base64:')) {
|
|
58
|
+
this.createStringAttachment(data, {
|
|
59
|
+
encoding: messages.AttachmentContentEncoding.BASE64,
|
|
60
|
+
contentType: options.mediaType.replace('base64:', ''),
|
|
61
|
+
}, options.fileName);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.createStringAttachment(data, {
|
|
65
|
+
encoding: messages.AttachmentContentEncoding.IDENTITY,
|
|
66
|
+
contentType: options.mediaType,
|
|
67
|
+
}, options.fileName);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw Error('Invalid attachment data: must be a buffer, readable stream, or string');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
createBufferAttachment(data, mediaType, fileName) {
|
|
75
|
+
this.createStringAttachment(data.toString('base64'), {
|
|
76
|
+
encoding: messages.AttachmentContentEncoding.BASE64,
|
|
77
|
+
contentType: mediaType,
|
|
78
|
+
}, fileName);
|
|
79
|
+
}
|
|
80
|
+
createStreamAttachment(data, mediaType, fileName, callback) {
|
|
81
|
+
const promise = new Promise((resolve, reject) => {
|
|
82
|
+
const buffers = [];
|
|
83
|
+
data.on('data', (chunk) => {
|
|
84
|
+
buffers.push(chunk);
|
|
85
|
+
});
|
|
86
|
+
data.on('end', () => {
|
|
87
|
+
this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName);
|
|
88
|
+
resolve();
|
|
89
|
+
});
|
|
90
|
+
data.on('error', reject);
|
|
91
|
+
});
|
|
92
|
+
if ((0, value_checker_1.doesHaveValue)(callback)) {
|
|
93
|
+
promise.then(callback, callback);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return promise;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
createStringAttachment(data, media, fileName) {
|
|
100
|
+
this.onAttachment({
|
|
101
|
+
data,
|
|
102
|
+
media,
|
|
103
|
+
...(fileName ? { fileName } : {}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.default = AttachmentManager;
|
|
108
|
+
function normaliseOptions(mediaTypeOrOptions) {
|
|
109
|
+
if (!mediaTypeOrOptions) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
if (typeof mediaTypeOrOptions === 'string') {
|
|
113
|
+
return {
|
|
114
|
+
mediaType: mediaTypeOrOptions,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return mediaTypeOrOptions;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAgC;AAEhC,6DAA8C;AAC9C,uDAAqE;AA0CrE,MAAqB,iBAAiB;IAGpC,YAAY,YAA6B;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,2BAA2B,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CACJ,IAAgC,EAChC,kBAAsD,EACtD,QAAqB;QAErB,MAAM,OAAO,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;QACpD,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACzB,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C;CACF;AAhHD,oCAgHC;AAED,SAAS,gBAAgB,CACvB,kBAAsD;IAEtD,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,EAAE,CAAA;KACV;IACD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;QAC1C,OAAO;YACL,SAAS,EAAE,kBAAkB;SAC9B,CAAA;KACF;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import isStream from 'is-stream'\nimport { Readable } from 'stream'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\nexport interface IAttachmentMedia {\n encoding: messages.AttachmentContentEncoding\n contentType: string\n}\n\nexport interface IAttachment {\n data: string\n media: IAttachmentMedia\n fileName?: string\n}\n\nexport type IAttachFunction = (attachment: IAttachment) => void\n\nexport interface ICreateAttachmentOptions {\n mediaType: string\n fileName?: string\n}\nexport type ICreateStringAttachment = (\n data: string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n) => void\nexport type ICreateBufferAttachment = (\n data: Buffer,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => void\nexport type ICreateStreamAttachment = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => Promise<void>\nexport type ICreateStreamAttachmentWithCallback = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions,\n callback: () => void\n) => void\nexport type ICreateAttachment = ICreateStringAttachment &\n ICreateBufferAttachment &\n ICreateStreamAttachment &\n ICreateStreamAttachmentWithCallback\nexport type ICreateLog = (text: string) => void\n\nexport default class AttachmentManager {\n private readonly onAttachment: IAttachFunction\n\n constructor(onAttachment: IAttachFunction) {\n this.onAttachment = onAttachment\n }\n\n log(text: string): void | Promise<void> {\n return this.create(text, 'text/x.cucumber.log+plain')\n }\n\n create(\n data: Buffer | Readable | string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions,\n callback?: () => void\n ): void | Promise<void> {\n const options = normaliseOptions(mediaTypeOrOptions)\n if (Buffer.isBuffer(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Buffer attachments must specify a media type')\n }\n this.createBufferAttachment(data, options.mediaType, options.fileName)\n } else if (isStream.readable(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Stream attachments must specify a media type')\n }\n return this.createStreamAttachment(\n data,\n options.mediaType,\n options.fileName,\n callback\n )\n } else if (typeof data === 'string') {\n if (doesNotHaveValue(options.mediaType)) {\n options.mediaType = 'text/plain'\n }\n if (options.mediaType.startsWith('base64:')) {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: options.mediaType.replace('base64:', ''),\n },\n options.fileName\n )\n } else {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.IDENTITY,\n contentType: options.mediaType,\n },\n options.fileName\n )\n }\n } else {\n throw Error(\n 'Invalid attachment data: must be a buffer, readable stream, or string'\n )\n }\n }\n\n createBufferAttachment(\n data: Buffer,\n mediaType: string,\n fileName?: string\n ): void {\n this.createStringAttachment(\n data.toString('base64'),\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType,\n },\n fileName\n )\n }\n\n createStreamAttachment(\n data: Readable,\n mediaType: string,\n fileName?: string,\n callback?: () => void\n ): void | Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n const buffers: Uint8Array[] = []\n data.on('data', (chunk) => {\n buffers.push(chunk)\n })\n data.on('end', () => {\n this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName)\n resolve()\n })\n data.on('error', reject)\n })\n if (doesHaveValue(callback)) {\n promise.then(callback, callback)\n } else {\n return promise\n }\n }\n\n createStringAttachment(\n data: string,\n media: IAttachmentMedia,\n fileName?: string\n ): void {\n this.onAttachment({\n data,\n media,\n ...(fileName ? { fileName } : {}),\n })\n }\n}\n\nfunction normaliseOptions(\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n): Partial<ICreateAttachmentOptions> {\n if (!mediaTypeOrOptions) {\n return {}\n }\n if (typeof mediaTypeOrOptions === 'string') {\n return {\n mediaType: mediaTypeOrOptions,\n }\n }\n return mediaTypeOrOptions\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatError = void 0;
|
|
7
|
+
const assertion_error_formatter_1 = require("assertion-error-formatter");
|
|
8
|
+
const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
|
|
9
|
+
const filter_stack_trace_1 = require("../filter_stack_trace");
|
|
10
|
+
function formatError(error, filterStackTraces) {
|
|
11
|
+
let filteredStack;
|
|
12
|
+
if (filterStackTraces) {
|
|
13
|
+
try {
|
|
14
|
+
filteredStack = (0, filter_stack_trace_1.filterStackTrace)(error_stack_parser_1.default.parse(error))
|
|
15
|
+
.map((f) => f.source)
|
|
16
|
+
.join('\n');
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
// if we weren't able to parse and filter, we'll settle for the original
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const message = (0, assertion_error_formatter_1.format)(error, {
|
|
23
|
+
colorFns: {
|
|
24
|
+
errorStack: (stack) => filteredStack ? `\n${filteredStack}` : stack,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
message,
|
|
29
|
+
exception: {
|
|
30
|
+
type: error.name || 'Error',
|
|
31
|
+
message: typeof error === 'string' ? error : error.message,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.formatError = formatError;
|
|
36
|
+
//# sourceMappingURL=format_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format_error.js","sourceRoot":"","sources":["../../src/runtime/format_error.ts"],"names":[],"mappings":";;;;;;AACA,yEAAkD;AAClD,4EAAiD;AACjD,8DAAwD;AAExD,SAAgB,WAAW,CACzB,KAAY,EACZ,iBAA0B;IAE1B,IAAI,aAAqB,CAAA;IACzB,IAAI,iBAAiB,EAAE;QACrB,IAAI;YACF,aAAa,GAAG,IAAA,qCAAgB,EAAC,4BAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,CAAA;SACd;QAAC,WAAM;YACN,wEAAwE;SACzE;KACF;IACD,MAAM,OAAO,GAAG,IAAA,kCAAM,EAAC,KAAK,EAAE;QAC5B,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAC5B,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK;SAC/C;KACF,CAAC,CAAA;IACF,OAAO;QACL,OAAO;QACP,SAAS,EAAE;YACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;YAC3B,OAAO,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO;SAC3D;KACF,CAAA;AACH,CAAC;AA3BD,kCA2BC","sourcesContent":["import { TestStepResult } from '@cucumber/messages'\nimport { format } from 'assertion-error-formatter'\nimport errorStackParser from 'error-stack-parser'\nimport { filterStackTrace } from '../filter_stack_trace'\n\nexport function formatError(\n error: Error,\n filterStackTraces: boolean\n): Pick<TestStepResult, 'message' | 'exception'> {\n let filteredStack: string\n if (filterStackTraces) {\n try {\n filteredStack = filterStackTrace(errorStackParser.parse(error))\n .map((f) => f.source)\n .join('\\n')\n } catch {\n // if we weren't able to parse and filter, we'll settle for the original\n }\n }\n const message = format(error, {\n colorFns: {\n errorStack: (stack: string) =>\n filteredStack ? `\\n${filteredStack}` : stack,\n },\n })\n return {\n message,\n exception: {\n type: error.name || 'Error',\n message: typeof error === 'string' ? error : error.message,\n },\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import StepDefinition from '../models/step_definition';
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { IRuntimeOptions } from '.';
|
|
4
|
+
export declare function getAmbiguousStepException(stepDefinitions: StepDefinition[]): string;
|
|
5
|
+
export declare function retriesForPickle(pickle: messages.Pickle, options: IRuntimeOptions): number;
|
|
6
|
+
export declare function shouldCauseFailure(status: messages.TestStepResultStatus, options: IRuntimeOptions): boolean;
|