@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 @@
|
|
|
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,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AC,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;YACzD,MAAM;YACN,kBAAkB;YAClB,KAAK;SACN,CAAC,CAAA;QACF,MAAM,cAAc,GAAwB,kBAAkB,CAAC;YAC7D,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,QAAQ,GAAsB;YAClC,QAAQ;YACR,EAAE,EAAE,UAAU;YACd,SAAS,EAAE;gBACT,GAAG,eAAe;gBAClB,GAAG,mBAAmB;gBACtB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I,CAAC,CACpE,CAAA;QACD,OAAO;YACL,EAAE,EAAE,KAAK,EAAE;YACX,YAAY,EAAE,UAAU,CAAC,EAAE;YAC3B,iBAAiB,EAAE,eAAe,CAAC,GAAG,CACpC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CACtC;YACD,uBAAuB,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;gBAC9D,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;gBAC/D,OAAO;oBACL,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;wBACrC,OAAO;4BACL,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;4BAClC,iBAAiB,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI;yBAC1C,CAAA;oBACH,CAAC,CAAC;iBACH,CAAA;YACH,CAAC,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAY;IACpC,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,IAAA,6BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;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,IAAI,IAAA,gCAAgB,EAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBACvC,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA;aAC5D;YACD,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;SACvE;aAAM,IAAI,mBAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;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ream 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;
|
|
@@ -0,0 +1,101 @@
|
|
|
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.shouldCauseFailure = exports.retriesForPickle = exports.getAmbiguousStepException = void 0;
|
|
30
|
+
const location_helpers_1 = require("../formatter/helpers/location_helpers");
|
|
31
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
32
|
+
const indent_string_1 = __importDefault(require("indent-string"));
|
|
33
|
+
const pickle_filter_1 = require("../pickle_filter");
|
|
34
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
35
|
+
function getAmbiguousStepException(stepDefinitions) {
|
|
36
|
+
const table = new cli_table3_1.default({
|
|
37
|
+
chars: {
|
|
38
|
+
bottom: '',
|
|
39
|
+
'bottom-left': '',
|
|
40
|
+
'bottom-mid': '',
|
|
41
|
+
'bottom-right': '',
|
|
42
|
+
left: '',
|
|
43
|
+
'left-mid': '',
|
|
44
|
+
mid: '',
|
|
45
|
+
'mid-mid': '',
|
|
46
|
+
middle: ' - ',
|
|
47
|
+
right: '',
|
|
48
|
+
'right-mid': '',
|
|
49
|
+
top: '',
|
|
50
|
+
'top-left': '',
|
|
51
|
+
'top-mid': '',
|
|
52
|
+
'top-right': '',
|
|
53
|
+
},
|
|
54
|
+
style: {
|
|
55
|
+
border: [],
|
|
56
|
+
'padding-left': 0,
|
|
57
|
+
'padding-right': 0,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
table.push(...stepDefinitions.map((stepDefinition) => {
|
|
61
|
+
const pattern = stepDefinition.pattern.toString();
|
|
62
|
+
return [pattern, (0, location_helpers_1.formatLocation)(stepDefinition)];
|
|
63
|
+
}));
|
|
64
|
+
return `${'Multiple step definitions match:' + '\n'}${(0, indent_string_1.default)(table.toString(), 2)}`;
|
|
65
|
+
}
|
|
66
|
+
exports.getAmbiguousStepException = getAmbiguousStepException;
|
|
67
|
+
function retriesForPickle(pickle, options) {
|
|
68
|
+
if (!options.retry) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
const retries = options.retry;
|
|
72
|
+
if (retries === 0) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
const retryTagFilter = options.retryTagFilter;
|
|
76
|
+
if (!retryTagFilter) {
|
|
77
|
+
return retries;
|
|
78
|
+
}
|
|
79
|
+
const pickleTagFilter = new pickle_filter_1.PickleTagFilter(retryTagFilter);
|
|
80
|
+
if (pickleTagFilter.matchesAllTagExpressions(pickle)) {
|
|
81
|
+
return retries;
|
|
82
|
+
}
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
exports.retriesForPickle = retriesForPickle;
|
|
86
|
+
function shouldCauseFailure(status, options) {
|
|
87
|
+
if (options.dryRun) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const failureStatuses = [
|
|
91
|
+
messages.TestStepResultStatus.AMBIGUOUS,
|
|
92
|
+
messages.TestStepResultStatus.FAILED,
|
|
93
|
+
messages.TestStepResultStatus.UNDEFINED,
|
|
94
|
+
];
|
|
95
|
+
if (options.strict) {
|
|
96
|
+
failureStatuses.push(messages.TestStepResultStatus.PENDING);
|
|
97
|
+
}
|
|
98
|
+
return failureStatuses.includes(status);
|
|
99
|
+
}
|
|
100
|
+
exports.shouldCauseFailure = shouldCauseFailure;
|
|
101
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAsE;AACtE,4DAA8B;AAC9B,kEAAwC;AACxC,oDAAkD;AAElD,6DAA8C;AAG9C,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAA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AAM,eAAe,GAAoC;QACvD,QAAQ,CAAC,oBAAoB,CAAC,SAAS;QACvC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;QACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;KACxC,CAAA;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC5D;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","sourcesContent":["import { formatLocation } from '../formatter/helpers/location_helpers'\nimport Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport * as messages from '@cucumber/messages'\nimport { IRuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: IRuntimeOptions\n): number {\n if (!options.retry) {\n return 0\n }\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (!retryTagFilter) {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: IRuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { EventDataCollector } from '../formatter/helpers';
|
|
6
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
|
+
export interface IRuntime {
|
|
8
|
+
start: () => Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
export interface INewRuntimeOptions {
|
|
11
|
+
eventBroadcaster: EventEmitter;
|
|
12
|
+
eventDataCollector: EventDataCollector;
|
|
13
|
+
newId: IdGenerator.NewId;
|
|
14
|
+
options: IRuntimeOptions;
|
|
15
|
+
pickleIds: string[];
|
|
16
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
17
|
+
}
|
|
18
|
+
export interface IRuntimeOptions {
|
|
19
|
+
dryRun: boolean;
|
|
20
|
+
failFast: boolean;
|
|
21
|
+
filterStacktraces: boolean;
|
|
22
|
+
retry: number;
|
|
23
|
+
retryTagFilter: string;
|
|
24
|
+
strict: boolean;
|
|
25
|
+
worldParameters: any;
|
|
26
|
+
}
|
|
27
|
+
export default class Runtime implements IRuntime {
|
|
28
|
+
private readonly eventBroadcaster;
|
|
29
|
+
private readonly eventDataCollector;
|
|
30
|
+
private readonly stopwatch;
|
|
31
|
+
private readonly newId;
|
|
32
|
+
private readonly options;
|
|
33
|
+
private readonly pickleIds;
|
|
34
|
+
private readonly supportCodeLibrary;
|
|
35
|
+
private success;
|
|
36
|
+
private runTestRunHooks;
|
|
37
|
+
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
|
|
38
|
+
runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
|
|
39
|
+
start(): Promise<boolean>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 assemble_test_cases_1 = require("./assemble_test_cases");
|
|
7
|
+
const helpers_1 = require("./helpers");
|
|
8
|
+
const run_test_run_hooks_1 = require("./run_test_run_hooks");
|
|
9
|
+
const stopwatch_1 = require("./stopwatch");
|
|
10
|
+
const test_case_runner_1 = __importDefault(require("./test_case_runner"));
|
|
11
|
+
class Runtime {
|
|
12
|
+
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
|
|
13
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
14
|
+
this.eventDataCollector = eventDataCollector;
|
|
15
|
+
this.stopwatch = (0, stopwatch_1.create)();
|
|
16
|
+
this.newId = newId;
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.pickleIds = pickleIds;
|
|
19
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
20
|
+
this.success = true;
|
|
21
|
+
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored, process exiting: ${location}`);
|
|
22
|
+
}
|
|
23
|
+
async runTestCase(pickleId, testCase) {
|
|
24
|
+
const pickle = this.eventDataCollector.getPickle(pickleId);
|
|
25
|
+
const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
|
|
26
|
+
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
27
|
+
const testCaseRunner = new test_case_runner_1.default({
|
|
28
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
29
|
+
stopwatch: this.stopwatch,
|
|
30
|
+
gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),
|
|
31
|
+
newId: this.newId,
|
|
32
|
+
pickle,
|
|
33
|
+
testCase,
|
|
34
|
+
retries,
|
|
35
|
+
skip,
|
|
36
|
+
filterStackTraces: this.options.filterStacktraces,
|
|
37
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
38
|
+
worldParameters: this.options.worldParameters,
|
|
39
|
+
});
|
|
40
|
+
const status = await testCaseRunner.run();
|
|
41
|
+
if ((0, helpers_1.shouldCauseFailure)(status, this.options)) {
|
|
42
|
+
this.success = false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async start() {
|
|
46
|
+
const testRunStarted = {
|
|
47
|
+
testRunStarted: {
|
|
48
|
+
timestamp: this.stopwatch.timestamp(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
this.eventBroadcaster.emit('envelope', testRunStarted);
|
|
52
|
+
this.stopwatch.start();
|
|
53
|
+
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
54
|
+
const assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
|
|
55
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
56
|
+
newId: this.newId,
|
|
57
|
+
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
58
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
59
|
+
});
|
|
60
|
+
for (const pickleId of this.pickleIds) {
|
|
61
|
+
await this.runTestCase(pickleId, assembledTestCases[pickleId]);
|
|
62
|
+
}
|
|
63
|
+
await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(), 'an AfterAll');
|
|
64
|
+
this.stopwatch.stop();
|
|
65
|
+
const testRunFinished = {
|
|
66
|
+
testRunFinished: {
|
|
67
|
+
timestamp: this.stopwatch.timestamp(),
|
|
68
|
+
success: this.success,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
this.eventBroadcaster.emit('envelope', testRunFinished);
|
|
72
|
+
return this.success;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = Runtime;
|
|
76
|
+
//# sourceMappingURL=index.js.map
|