@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,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadSources = void 0;
|
|
4
|
+
const paths_1 = require("./paths");
|
|
5
|
+
const messages_1 = require("@cucumber/messages");
|
|
6
|
+
const environment_1 = require("./environment");
|
|
7
|
+
const gherkin_1 = require("./gherkin");
|
|
8
|
+
const console_logger_1 = require("./console_logger");
|
|
9
|
+
/**
|
|
10
|
+
* Load and parse features, produce a filtered and ordered test plan and/or parse errors.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param coordinates - Coordinates required to find features
|
|
14
|
+
* @param environment - Project environment.
|
|
15
|
+
*/
|
|
16
|
+
async function loadSources(coordinates, environment = {}) {
|
|
17
|
+
const { cwd, stderr, debug } = (0, environment_1.mergeEnvironment)(environment);
|
|
18
|
+
const logger = new console_logger_1.ConsoleLogger(stderr, debug);
|
|
19
|
+
const newId = messages_1.IdGenerator.uuid();
|
|
20
|
+
const { unexpandedFeaturePaths, featurePaths } = await (0, paths_1.resolvePaths)(logger, cwd, coordinates);
|
|
21
|
+
if (featurePaths.length === 0) {
|
|
22
|
+
return {
|
|
23
|
+
plan: [],
|
|
24
|
+
errors: [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const { filteredPickles, parseErrors } = await (0, gherkin_1.getFilteredPicklesAndErrors)({
|
|
28
|
+
newId,
|
|
29
|
+
cwd,
|
|
30
|
+
logger,
|
|
31
|
+
unexpandedFeaturePaths,
|
|
32
|
+
featurePaths,
|
|
33
|
+
coordinates,
|
|
34
|
+
});
|
|
35
|
+
const plan = filteredPickles.map(({ location, pickle }) => ({
|
|
36
|
+
name: pickle.name,
|
|
37
|
+
uri: pickle.uri,
|
|
38
|
+
location,
|
|
39
|
+
}));
|
|
40
|
+
const errors = parseErrors.map(({ source, message }) => {
|
|
41
|
+
return {
|
|
42
|
+
uri: source.uri,
|
|
43
|
+
location: source.location,
|
|
44
|
+
message,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
plan,
|
|
49
|
+
errors,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.loadSources = loadSources;
|
|
53
|
+
//# sourceMappingURL=load_sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load_sources.js","sourceRoot":"","sources":["../../src/api/load_sources.ts"],"names":[],"mappings":";;;AAOA,mCAAsC;AACtC,iDAAgD;AAChD,+CAAgD;AAChD,uCAAuD;AACvD,qDAAgD;AAGhD;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAC/B,WAAgC,EAChC,cAA+B,EAAE;IAEjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAY,IAAI,8BAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;IAChC,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAY,EACjE,MAAM,EACN,GAAG,EACH,WAAW,CACZ,CAAA;IACD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO;YACL,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,EAAE;SACX,CAAA;KACF;IACD,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,qCAA2B,EAAC;QACzE,KAAK;QACL,GAAG;QACH,MAAM;QACN,sBAAsB;QACtB,YAAY;QACZ,WAAW;KACZ,CAAC,CAAA;IACF,MAAM,IAAI,GAAqB,eAAe,CAAC,GAAG,CAChD,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ;KACT,CAAC,CACH,CAAA;IACD,MAAM,MAAM,GAAoB,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QACtE,OAAO;YACL,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO;SACR,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO;QACL,IAAI;QACJ,MAAM;KACP,CAAA;AACH,CAAC;AA5CD,kCA4CC","sourcesContent":["import {\n ILoadSourcesResult,\n IPlannedPickle,\n IRunEnvironment,\n ISourcesCoordinates,\n ISourcesError,\n} from './types'\nimport { resolvePaths } from './paths'\nimport { IdGenerator } from '@cucumber/messages'\nimport { mergeEnvironment } from './environment'\nimport { getFilteredPicklesAndErrors } from './gherkin'\nimport { ConsoleLogger } from './console_logger'\nimport { ILogger } from '../logger'\n\n/**\n * Load and parse features, produce a filtered and ordered test plan and/or parse errors.\n *\n * @public\n * @param coordinates - Coordinates required to find features\n * @param environment - Project environment.\n */\nexport async function loadSources(\n coordinates: ISourcesCoordinates,\n environment: IRunEnvironment = {}\n): Promise<ILoadSourcesResult> {\n const { cwd, stderr, debug } = mergeEnvironment(environment)\n const logger: ILogger = new ConsoleLogger(stderr, debug)\n const newId = IdGenerator.uuid()\n const { unexpandedFeaturePaths, featurePaths } = await resolvePaths(\n logger,\n cwd,\n coordinates\n )\n if (featurePaths.length === 0) {\n return {\n plan: [],\n errors: [],\n }\n }\n const { filteredPickles, parseErrors } = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates,\n })\n const plan: IPlannedPickle[] = filteredPickles.map(\n ({ location, pickle }) => ({\n name: pickle.name,\n uri: pickle.uri,\n location,\n })\n )\n const errors: ISourcesError[] = parseErrors.map(({ source, message }) => {\n return {\n uri: source.uri,\n location: source.location,\n message,\n }\n })\n return {\n plan,\n errors,\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ILoadSupportOptions, IRunEnvironment } from './types';
|
|
2
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
3
|
+
/**
|
|
4
|
+
* Load support code for use in test runs.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @param options - Subset of `IRunnableConfiguration` required to find the support code.
|
|
8
|
+
* @param environment - Project environment.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadSupport(options: ILoadSupportOptions, environment?: IRunEnvironment): Promise<ISupportCodeLibrary>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadSupport = void 0;
|
|
4
|
+
const messages_1 = require("@cucumber/messages");
|
|
5
|
+
const paths_1 = require("./paths");
|
|
6
|
+
const support_1 = require("./support");
|
|
7
|
+
const environment_1 = require("./environment");
|
|
8
|
+
const console_logger_1 = require("./console_logger");
|
|
9
|
+
/**
|
|
10
|
+
* Load support code for use in test runs.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param options - Subset of `IRunnableConfiguration` required to find the support code.
|
|
14
|
+
* @param environment - Project environment.
|
|
15
|
+
*/
|
|
16
|
+
async function loadSupport(options, environment = {}) {
|
|
17
|
+
const { cwd, stderr, debug } = (0, environment_1.mergeEnvironment)(environment);
|
|
18
|
+
const logger = new console_logger_1.ConsoleLogger(stderr, debug);
|
|
19
|
+
const newId = messages_1.IdGenerator.uuid();
|
|
20
|
+
const { requirePaths, importPaths } = await (0, paths_1.resolvePaths)(logger, cwd, options.sources, options.support);
|
|
21
|
+
return await (0, support_1.getSupportCodeLibrary)({
|
|
22
|
+
cwd,
|
|
23
|
+
newId,
|
|
24
|
+
requireModules: options.support.requireModules,
|
|
25
|
+
requirePaths,
|
|
26
|
+
importPaths,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.loadSupport = loadSupport;
|
|
30
|
+
//# sourceMappingURL=load_support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load_support.js","sourceRoot":"","sources":["../../src/api/load_support.ts"],"names":[],"mappings":";;;AAAA,iDAAgD;AAEhD,mCAAsC;AACtC,uCAAiD;AACjD,+CAAgD;AAGhD,qDAAgD;AAEhD;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAC/B,OAA4B,EAC5B,cAA+B,EAAE;IAEjC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAY,IAAI,8BAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;IAChC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,oBAAY,EACtD,MAAM,EACN,GAAG,EACH,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,CAChB,CAAA;IACD,OAAO,MAAM,IAAA,+BAAqB,EAAC;QACjC,GAAG;QACH,KAAK;QACL,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc;QAC9C,YAAY;QACZ,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC;AApBD,kCAoBC","sourcesContent":["import { IdGenerator } from '@cucumber/messages'\nimport { ILoadSupportOptions, IRunEnvironment } from './types'\nimport { resolvePaths } from './paths'\nimport { getSupportCodeLibrary } from './support'\nimport { mergeEnvironment } from './environment'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { ILogger } from '../logger'\nimport { ConsoleLogger } from './console_logger'\n\n/**\n * Load support code for use in test runs.\n *\n * @public\n * @param options - Subset of `IRunnableConfiguration` required to find the support code.\n * @param environment - Project environment.\n */\nexport async function loadSupport(\n options: ILoadSupportOptions,\n environment: IRunEnvironment = {}\n): Promise<ISupportCodeLibrary> {\n const { cwd, stderr, debug } = mergeEnvironment(environment)\n const logger: ILogger = new ConsoleLogger(stderr, debug)\n const newId = IdGenerator.uuid()\n const { requirePaths, importPaths } = await resolvePaths(\n logger,\n cwd,\n options.sources,\n options.support\n )\n return await getSupportCodeLibrary({\n cwd,\n newId,\n requireModules: options.support.requireModules,\n requirePaths,\n importPaths,\n })\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ISourcesCoordinates, ISupportCodeCoordinates } from './types';
|
|
2
|
+
import { ILogger } from '../logger';
|
|
3
|
+
export declare function resolvePaths(logger: ILogger, cwd: string, sources: Pick<ISourcesCoordinates, 'paths'>, support?: ISupportCodeCoordinates): Promise<{
|
|
4
|
+
unexpandedFeaturePaths: string[];
|
|
5
|
+
featurePaths: string[];
|
|
6
|
+
requirePaths: string[];
|
|
7
|
+
importPaths: string[];
|
|
8
|
+
}>;
|
package/lib/api/paths.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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.resolvePaths = void 0;
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const glob_1 = __importDefault(require("glob"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const fs_1 = __importDefault(require("mz/fs"));
|
|
11
|
+
async function resolvePaths(logger, cwd, sources, support = {
|
|
12
|
+
requireModules: [],
|
|
13
|
+
requirePaths: [],
|
|
14
|
+
importPaths: [],
|
|
15
|
+
}) {
|
|
16
|
+
const unexpandedFeaturePaths = await getUnexpandedFeaturePaths(cwd, sources.paths);
|
|
17
|
+
const featurePaths = await expandFeaturePaths(cwd, unexpandedFeaturePaths);
|
|
18
|
+
logger.debug('Found feature files based on configuration:', featurePaths);
|
|
19
|
+
const { requirePaths, importPaths } = await deriveSupportPaths(cwd, featurePaths, support.requirePaths, support.importPaths);
|
|
20
|
+
logger.debug('Found support files to load via `require` based on configuration:', requirePaths);
|
|
21
|
+
logger.debug('Found support files to load via `import` based on configuration:', importPaths);
|
|
22
|
+
return {
|
|
23
|
+
unexpandedFeaturePaths,
|
|
24
|
+
featurePaths,
|
|
25
|
+
requirePaths,
|
|
26
|
+
importPaths,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.resolvePaths = resolvePaths;
|
|
30
|
+
async function expandPaths(cwd, unexpandedPaths, defaultExtension) {
|
|
31
|
+
const expandedPaths = await Promise.all(unexpandedPaths.map(async (unexpandedPath) => {
|
|
32
|
+
const matches = await (0, util_1.promisify)(glob_1.default)(unexpandedPath, {
|
|
33
|
+
absolute: true,
|
|
34
|
+
cwd,
|
|
35
|
+
});
|
|
36
|
+
const expanded = await Promise.all(matches.map(async (match) => {
|
|
37
|
+
if (path_1.default.extname(match) === '') {
|
|
38
|
+
return await (0, util_1.promisify)(glob_1.default)(`${match}/**/*${defaultExtension}`);
|
|
39
|
+
}
|
|
40
|
+
return [match];
|
|
41
|
+
}));
|
|
42
|
+
return expanded.flat();
|
|
43
|
+
}));
|
|
44
|
+
const normalized = expandedPaths.flat().map((x) => path_1.default.normalize(x));
|
|
45
|
+
return [...new Set(normalized)];
|
|
46
|
+
}
|
|
47
|
+
async function getUnexpandedFeaturePaths(cwd, args) {
|
|
48
|
+
if (args.length > 0) {
|
|
49
|
+
const nestedFeaturePaths = await Promise.all(args.map(async (arg) => {
|
|
50
|
+
const filename = path_1.default.basename(arg);
|
|
51
|
+
if (filename[0] === '@') {
|
|
52
|
+
const filePath = path_1.default.join(cwd, arg);
|
|
53
|
+
const content = await fs_1.default.readFile(filePath, 'utf8');
|
|
54
|
+
return content.split('\n').map((x) => x.trim());
|
|
55
|
+
}
|
|
56
|
+
return [arg];
|
|
57
|
+
}));
|
|
58
|
+
const featurePaths = nestedFeaturePaths.flat();
|
|
59
|
+
if (featurePaths.length > 0) {
|
|
60
|
+
return featurePaths.filter((x) => x !== '');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return ['features/**/*.{feature,feature.md}'];
|
|
64
|
+
}
|
|
65
|
+
function getFeatureDirectoryPaths(cwd, featurePaths) {
|
|
66
|
+
const featureDirs = featurePaths.map((featurePath) => {
|
|
67
|
+
let featureDir = path_1.default.dirname(featurePath);
|
|
68
|
+
let childDir;
|
|
69
|
+
let parentDir = featureDir;
|
|
70
|
+
while (childDir !== parentDir) {
|
|
71
|
+
childDir = parentDir;
|
|
72
|
+
parentDir = path_1.default.dirname(childDir);
|
|
73
|
+
if (path_1.default.basename(parentDir) === 'features') {
|
|
74
|
+
featureDir = parentDir;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return path_1.default.relative(cwd, featureDir);
|
|
79
|
+
});
|
|
80
|
+
return [...new Set(featureDirs)];
|
|
81
|
+
}
|
|
82
|
+
async function expandFeaturePaths(cwd, featurePaths) {
|
|
83
|
+
featurePaths = featurePaths.map((p) => p.replace(/(:\d+)*$/g, '')); // Strip line numbers
|
|
84
|
+
return await expandPaths(cwd, featurePaths, '.feature');
|
|
85
|
+
}
|
|
86
|
+
async function deriveSupportPaths(cwd, featurePaths, unexpandedRequirePaths, unexpandedImportPaths) {
|
|
87
|
+
if (unexpandedRequirePaths.length === 0 &&
|
|
88
|
+
unexpandedImportPaths.length === 0) {
|
|
89
|
+
const defaultPaths = getFeatureDirectoryPaths(cwd, featurePaths);
|
|
90
|
+
const requirePaths = await expandPaths(cwd, defaultPaths, '.js');
|
|
91
|
+
const importPaths = await expandPaths(cwd, defaultPaths, '.mjs');
|
|
92
|
+
return { requirePaths, importPaths };
|
|
93
|
+
}
|
|
94
|
+
const requirePaths = unexpandedRequirePaths.length > 0
|
|
95
|
+
? await expandPaths(cwd, unexpandedRequirePaths, '.js')
|
|
96
|
+
: [];
|
|
97
|
+
const importPaths = unexpandedImportPaths.length > 0
|
|
98
|
+
? await expandPaths(cwd, unexpandedImportPaths, '.@(js|cjs|mjs)')
|
|
99
|
+
: [];
|
|
100
|
+
return { requirePaths, importPaths };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/api/paths.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAgC;AAChC,gDAAuB;AACvB,gDAAuB;AACvB,+CAAsB;AAIf,KAAK,UAAU,YAAY,CAChC,MAAe,EACf,GAAW,EACX,OAA2C,EAC3C,UAAmC;IACjC,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,EAAE;IAChB,WAAW,EAAE,EAAE;CAChB;IAOD,MAAM,sBAAsB,GAAG,MAAM,yBAAyB,CAC5D,GAAG,EACH,OAAO,CAAC,KAAK,CACd,CAAA;IACD,MAAM,YAAY,GAAa,MAAM,kBAAkB,CACrD,GAAG,EACH,sBAAsB,CACvB,CAAA;IACD,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,YAAY,CAAC,CAAA;IACzE,MAAM,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B,sBAAsB,CAAC,MAAM,GAAG,CAAC;QAC/B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,CAAC;QACvD,CAAC,CAAC,EAAE,CAAA;IACR,MAAM,WAAW,GACf,qBAAqB,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,qBAAqB,EAAE,gBAAgB,CAAC;QACjE,CAAC,CAAC,EAAE,CAAA;IACR,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA;AACtC,CAAC","sourcesContent":["import { promisify } from 'util'\nimport glob from 'glob'\nimport path from 'path'\nimport fs from 'mz/fs'\nimport { ISourcesCoordinates, ISupportCodeCoordinates } from './types'\nimport { ILogger } from '../logger'\n\nexport async function resolvePaths(\n logger: ILogger,\n cwd: string,\n sources: Pick<ISourcesCoordinates, 'paths'>,\n support: ISupportCodeCoordinates = {\n requireModules: [],\n requirePaths: [],\n importPaths: [],\n }\n): Promise<{\n unexpandedFeaturePaths: string[]\n featurePaths: string[]\n requirePaths: string[]\n importPaths: string[]\n}> {\n const unexpandedFeaturePaths = await getUnexpandedFeaturePaths(\n cwd,\n sources.paths\n )\n const featurePaths: string[] = await expandFeaturePaths(\n cwd,\n unexpandedFeaturePaths\n )\n logger.debug('Found feature files based on configuration:', featurePaths)\n const { requirePaths, importPaths } = await deriveSupportPaths(\n cwd,\n featurePaths,\n support.requirePaths,\n support.importPaths\n )\n logger.debug(\n 'Found support files to load via `require` based on configuration:',\n requirePaths\n )\n logger.debug(\n 'Found support files to load via `import` based on configuration:',\n importPaths\n )\n return {\n unexpandedFeaturePaths,\n featurePaths,\n requirePaths,\n importPaths,\n }\n}\n\nasync function expandPaths(\n cwd: string,\n unexpandedPaths: string[],\n defaultExtension: string\n): Promise<string[]> {\n const expandedPaths = await Promise.all(\n unexpandedPaths.map(async (unexpandedPath) => {\n const matches = await promisify(glob)(unexpandedPath, {\n absolute: true,\n cwd,\n })\n const expanded = await Promise.all(\n matches.map(async (match) => {\n if (path.extname(match) === '') {\n return await promisify(glob)(`${match}/**/*${defaultExtension}`)\n }\n return [match]\n })\n )\n return expanded.flat()\n })\n )\n const normalized = expandedPaths.flat().map((x) => path.normalize(x))\n return [...new Set(normalized)]\n}\n\nasync function getUnexpandedFeaturePaths(\n cwd: string,\n args: string[]\n): Promise<string[]> {\n if (args.length > 0) {\n const nestedFeaturePaths = await Promise.all(\n args.map(async (arg) => {\n const filename = path.basename(arg)\n if (filename[0] === '@') {\n const filePath = path.join(cwd, arg)\n const content = await fs.readFile(filePath, 'utf8')\n return content.split('\\n').map((x) => x.trim())\n }\n return [arg]\n })\n )\n const featurePaths = nestedFeaturePaths.flat()\n if (featurePaths.length > 0) {\n return featurePaths.filter((x) => x !== '')\n }\n }\n return ['features/**/*.{feature,feature.md}']\n}\n\nfunction getFeatureDirectoryPaths(\n cwd: string,\n featurePaths: string[]\n): string[] {\n const featureDirs = featurePaths.map((featurePath) => {\n let featureDir = path.dirname(featurePath)\n let childDir: string\n let parentDir = featureDir\n while (childDir !== parentDir) {\n childDir = parentDir\n parentDir = path.dirname(childDir)\n if (path.basename(parentDir) === 'features') {\n featureDir = parentDir\n break\n }\n }\n return path.relative(cwd, featureDir)\n })\n return [...new Set(featureDirs)]\n}\n\nasync function expandFeaturePaths(\n cwd: string,\n featurePaths: string[]\n): Promise<string[]> {\n featurePaths = featurePaths.map((p) => p.replace(/(:\\d+)*$/g, '')) // Strip line numbers\n return await expandPaths(cwd, featurePaths, '.feature')\n}\n\nasync function deriveSupportPaths(\n cwd: string,\n featurePaths: string[],\n unexpandedRequirePaths: string[],\n unexpandedImportPaths: string[]\n): Promise<{\n requirePaths: string[]\n importPaths: string[]\n}> {\n if (\n unexpandedRequirePaths.length === 0 &&\n unexpandedImportPaths.length === 0\n ) {\n const defaultPaths = getFeatureDirectoryPaths(cwd, featurePaths)\n const requirePaths = await expandPaths(cwd, defaultPaths, '.js')\n const importPaths = await expandPaths(cwd, defaultPaths, '.mjs')\n return { requirePaths, importPaths }\n }\n const requirePaths =\n unexpandedRequirePaths.length > 0\n ? await expandPaths(cwd, unexpandedRequirePaths, '.js')\n : []\n const importPaths =\n unexpandedImportPaths.length > 0\n ? await expandPaths(cwd, unexpandedImportPaths, '.@(js|cjs|mjs)')\n : []\n return { requirePaths, importPaths }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PluginManager } from '../plugin';
|
|
2
|
+
import { IRunEnvironment, IRunOptions } from './types';
|
|
3
|
+
import { ILogger } from '../logger';
|
|
4
|
+
export declare function initializePlugins(logger: ILogger, configuration: IRunOptions, environment: IRunEnvironment): Promise<PluginManager>;
|
|
@@ -0,0 +1,19 @@
|
|
|
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.initializePlugins = void 0;
|
|
7
|
+
const plugin_1 = require("../plugin");
|
|
8
|
+
const publish_1 = __importDefault(require("../publish"));
|
|
9
|
+
const INTERNAL_PLUGINS = {
|
|
10
|
+
publish: publish_1.default,
|
|
11
|
+
};
|
|
12
|
+
async function initializePlugins(logger, configuration, environment) {
|
|
13
|
+
// eventually we'll load plugin packages here
|
|
14
|
+
const pluginManager = new plugin_1.PluginManager(Object.values(INTERNAL_PLUGINS));
|
|
15
|
+
await pluginManager.init(logger, configuration, environment);
|
|
16
|
+
return pluginManager;
|
|
17
|
+
}
|
|
18
|
+
exports.initializePlugins = initializePlugins;
|
|
19
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/api/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAiD;AACjD,yDAAsC;AAItC,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,iBAAa;CACvB,CAAA;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAe,EACf,aAA0B,EAC1B,WAA4B;IAE5B,6CAA6C;IAC7C,MAAM,aAAa,GAAG,IAAI,sBAAa,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACxE,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;IAC5D,OAAO,aAAa,CAAA;AACtB,CAAC;AATD,8CASC","sourcesContent":["import { Plugin, PluginManager } from '../plugin'\nimport publishPlugin from '../publish'\nimport { IRunEnvironment, IRunOptions } from './types'\nimport { ILogger } from '../logger'\n\nconst INTERNAL_PLUGINS: Record<string, Plugin> = {\n publish: publishPlugin,\n}\n\nexport async function initializePlugins(\n logger: ILogger,\n configuration: IRunOptions,\n environment: IRunEnvironment\n): Promise<PluginManager> {\n // eventually we'll load plugin packages here\n const pluginManager = new PluginManager(Object.values(INTERNAL_PLUGINS))\n await pluginManager.init(logger, configuration, environment)\n return pluginManager\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Envelope } from '@cucumber/messages';
|
|
2
|
+
import { IRunOptions, IRunEnvironment, IRunResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Execute a Cucumber test run.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @param configuration - Configuration loaded from `loadConfiguration`.
|
|
8
|
+
* @param environment - Project environment.
|
|
9
|
+
* @param onMessage - Callback fired each time Cucumber emits a message.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runCucumber(configuration: IRunOptions, environment?: IRunEnvironment, onMessage?: (message: Envelope) => void): Promise<IRunResult>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCucumber = void 0;
|
|
4
|
+
const messages_1 = require("@cucumber/messages");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const helpers_1 = require("../formatter/helpers");
|
|
7
|
+
const helpers_2 = require("../cli/helpers");
|
|
8
|
+
const paths_1 = require("./paths");
|
|
9
|
+
const runtime_1 = require("./runtime");
|
|
10
|
+
const formatters_1 = require("./formatters");
|
|
11
|
+
const support_1 = require("./support");
|
|
12
|
+
const environment_1 = require("./environment");
|
|
13
|
+
const gherkin_1 = require("./gherkin");
|
|
14
|
+
const plugins_1 = require("./plugins");
|
|
15
|
+
const console_logger_1 = require("./console_logger");
|
|
16
|
+
/**
|
|
17
|
+
* Execute a Cucumber test run.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
* @param configuration - Configuration loaded from `loadConfiguration`.
|
|
21
|
+
* @param environment - Project environment.
|
|
22
|
+
* @param onMessage - Callback fired each time Cucumber emits a message.
|
|
23
|
+
*/
|
|
24
|
+
async function runCucumber(configuration, environment = {}, onMessage) {
|
|
25
|
+
const { cwd, stdout, stderr, env, debug } = (0, environment_1.mergeEnvironment)(environment);
|
|
26
|
+
const logger = new console_logger_1.ConsoleLogger(stderr, debug);
|
|
27
|
+
const newId = messages_1.IdGenerator.uuid();
|
|
28
|
+
const supportCoordinates = 'World' in configuration.support
|
|
29
|
+
? configuration.support.originalCoordinates
|
|
30
|
+
: configuration.support;
|
|
31
|
+
const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } = await (0, paths_1.resolvePaths)(logger, cwd, configuration.sources, supportCoordinates);
|
|
32
|
+
const supportCodeLibrary = 'World' in configuration.support
|
|
33
|
+
? configuration.support
|
|
34
|
+
: await (0, support_1.getSupportCodeLibrary)({
|
|
35
|
+
cwd,
|
|
36
|
+
newId,
|
|
37
|
+
requirePaths,
|
|
38
|
+
importPaths,
|
|
39
|
+
requireModules: supportCoordinates.requireModules,
|
|
40
|
+
});
|
|
41
|
+
const plugins = await (0, plugins_1.initializePlugins)(logger, configuration, environment);
|
|
42
|
+
const eventBroadcaster = new events_1.EventEmitter();
|
|
43
|
+
if (onMessage) {
|
|
44
|
+
eventBroadcaster.on('envelope', onMessage);
|
|
45
|
+
}
|
|
46
|
+
eventBroadcaster.on('envelope', (value) => plugins.emit('message', value));
|
|
47
|
+
const eventDataCollector = new helpers_1.EventDataCollector(eventBroadcaster);
|
|
48
|
+
let formatterStreamError = false;
|
|
49
|
+
const cleanupFormatters = await (0, formatters_1.initializeFormatters)({
|
|
50
|
+
env,
|
|
51
|
+
cwd,
|
|
52
|
+
stdout,
|
|
53
|
+
stderr,
|
|
54
|
+
logger,
|
|
55
|
+
onStreamError: () => (formatterStreamError = true),
|
|
56
|
+
eventBroadcaster,
|
|
57
|
+
eventDataCollector,
|
|
58
|
+
configuration: configuration.formats,
|
|
59
|
+
supportCodeLibrary,
|
|
60
|
+
});
|
|
61
|
+
await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
|
|
62
|
+
let pickleIds = [];
|
|
63
|
+
let parseErrors = [];
|
|
64
|
+
if (featurePaths.length > 0) {
|
|
65
|
+
const gherkinResult = await (0, gherkin_1.getFilteredPicklesAndErrors)({
|
|
66
|
+
newId,
|
|
67
|
+
cwd,
|
|
68
|
+
logger,
|
|
69
|
+
unexpandedFeaturePaths,
|
|
70
|
+
featurePaths,
|
|
71
|
+
coordinates: configuration.sources,
|
|
72
|
+
onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),
|
|
73
|
+
});
|
|
74
|
+
pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id);
|
|
75
|
+
parseErrors = gherkinResult.parseErrors;
|
|
76
|
+
}
|
|
77
|
+
if (parseErrors.length) {
|
|
78
|
+
parseErrors.forEach((parseError) => {
|
|
79
|
+
logger.error(`Parse error in "${parseError.source.uri}" ${parseError.message}`);
|
|
80
|
+
});
|
|
81
|
+
await cleanupFormatters();
|
|
82
|
+
await plugins.cleanup();
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
support: supportCodeLibrary,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
(0, helpers_2.emitSupportCodeMessages)({
|
|
89
|
+
eventBroadcaster,
|
|
90
|
+
supportCodeLibrary,
|
|
91
|
+
newId,
|
|
92
|
+
});
|
|
93
|
+
const runtime = (0, runtime_1.makeRuntime)({
|
|
94
|
+
cwd,
|
|
95
|
+
logger,
|
|
96
|
+
eventBroadcaster,
|
|
97
|
+
eventDataCollector,
|
|
98
|
+
pickleIds,
|
|
99
|
+
newId,
|
|
100
|
+
supportCodeLibrary,
|
|
101
|
+
requireModules: supportCoordinates.requireModules,
|
|
102
|
+
requirePaths,
|
|
103
|
+
importPaths,
|
|
104
|
+
options: configuration.runtime,
|
|
105
|
+
});
|
|
106
|
+
const success = await runtime.start();
|
|
107
|
+
await cleanupFormatters();
|
|
108
|
+
await plugins.cleanup();
|
|
109
|
+
return {
|
|
110
|
+
success: success && !formatterStreamError,
|
|
111
|
+
support: supportCodeLibrary,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
exports.runCucumber = runCucumber;
|
|
115
|
+
//# sourceMappingURL=run_cucumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,mCAAqC;AACrC,kDAAyD;AACzD,4CAAyE;AAEzE,mCAAsC;AACtC,uCAAuC;AACvC,6CAAmD;AACnD,uCAAiD;AACjD,+CAAgD;AAChD,uCAAuD;AACvD,uCAA6C;AAC7C,qDAAgD;AAGhD;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAC/B,aAA0B,EAC1B,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IACzE,MAAM,MAAM,GAAY,IAAI,8BAAa,CAAC,MAAM,E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,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,GAAG;QACH,MAAM;QACN,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;QACT,KAAK;QACL,kBAAkB;QAClB,cAAc,EAAE,kBAAkB,CAAC,cAAc;QACjD,YAAY;QACZ,WAAW;QACX,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,iBAAiB,EAAE,CAAA;IACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IAEvB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA7GD,kCA6GC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { resolvePaths } from './paths'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { mergeEnvironment } from './environment'\nimport { getFilteredPicklesAndErrors } from './gherkin'\nimport { initializePlugins } from './plugins'\nimport { ConsoleLogger } from './console_logger'\nimport { ILogger } from '../logger'\n\n/**\n * Execute a Cucumber test run.\n *\n * @public\n * @param configuration - Configuration loaded from `loadConfiguration`.\n * @param environment - Project environment.\n * @param onMessage - Callback fired each time Cucumber emits a message.\n */\nexport async function runCucumber(\n configuration: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const { cwd, stdout, stderr, env, debug } = mergeEnvironment(environment)\n const logger: ILogger = new ConsoleLogger(stderr, debug)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'World' in configuration.support\n ? configuration.support.originalCoordinates\n : configuration.support\n\n const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } =\n await resolvePaths(logger, cwd, configuration.sources, supportCoordinates)\n\n const supportCodeLibrary =\n 'World' in configuration.support\n ? configuration.support\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const plugins = await initializePlugins(logger, configuration, environment)\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) => plugins.emit('message', value))\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (featurePaths.length > 0) {\n const gherkinResult = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates: configuration.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id)\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await plugins.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules: supportCoordinates.requireModules,\n requirePaths,\n importPaths,\n options: configuration.runtime,\n })\n const success = await runtime.start()\n await cleanupFormatters()\n await plugins.cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IRuntime } from '../runtime';
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import { EventDataCollector } from '../formatter/helpers';
|
|
5
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
6
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
|
+
import { IRunOptionsRuntime } from './types';
|
|
8
|
+
import { ILogger } from '../logger';
|
|
9
|
+
export declare function makeRuntime({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, options: { parallel, ...options }, }: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
logger: ILogger;
|
|
12
|
+
eventBroadcaster: EventEmitter;
|
|
13
|
+
eventDataCollector: EventDataCollector;
|
|
14
|
+
newId: IdGenerator.NewId;
|
|
15
|
+
pickleIds: string[];
|
|
16
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
17
|
+
requireModules: string[];
|
|
18
|
+
requirePaths: string[];
|
|
19
|
+
importPaths: string[];
|
|
20
|
+
options: IRunOptionsRuntime;
|
|
21
|
+
}): IRuntime;
|
|
@@ -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.makeRuntime = void 0;
|
|
7
|
+
const runtime_1 = __importDefault(require("../runtime"));
|
|
8
|
+
const coordinator_1 = __importDefault(require("../runtime/parallel/coordinator"));
|
|
9
|
+
function makeRuntime({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, options: { parallel, ...options }, }) {
|
|
10
|
+
if (parallel > 0) {
|
|
11
|
+
return new coordinator_1.default({
|
|
12
|
+
cwd,
|
|
13
|
+
logger,
|
|
14
|
+
eventBroadcaster,
|
|
15
|
+
eventDataCollector,
|
|
16
|
+
pickleIds,
|
|
17
|
+
options,
|
|
18
|
+
newId,
|
|
19
|
+
supportCodeLibrary,
|
|
20
|
+
requireModules,
|
|
21
|
+
requirePaths,
|
|
22
|
+
importPaths,
|
|
23
|
+
numberOfWorkers: parallel,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new runtime_1.default({
|
|
27
|
+
eventBroadcaster,
|
|
28
|
+
eventDataCollector,
|
|
29
|
+
newId,
|
|
30
|
+
pickleIds,
|
|
31
|
+
supportCodeLibrary,
|
|
32
|
+
options,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.makeRuntime = makeRuntime;
|
|
36
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA8C;AAK9C,kFAAyD;AAIzD,SAAgB,WAAW,CAAC,EAC1B,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,KAAK,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,GAalC;IACC,IAAI,QAAQ,GAAG,CAAC,EAAE;QAChB,OAAO,IAAI,qBAAW,CAAC;YACrB,GAAG;YACH,MAAM;YACN,gBAAgB;YAChB,kBAAkB;YAClB,SAAS;YACT,OAAO;YACP,KAAK;YACL,kBAAkB;YAClB,cAAc;YACd,YAAY;YACZ,WAAW;YACX,eAAe,EAAE,QAAQ;SAC1B,CAAC,CAAA;KACH;IACD,OAAO,IAAI,iBAAO,CAAC;QACjB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;QACL,SAAS;QACT,kBAAkB;QAClB,OAAO;KACR,CAAC,CAAA;AACJ,CAAC;AAjDD,kCAiDC","sourcesContent":["import Runtime, { IRuntime } from '../runtime'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Coordinator from '../runtime/parallel/coordinator'\nimport { IRunOptionsRuntime } from './types'\nimport { ILogger } from '../logger'\n\nexport function makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules,\n requirePaths,\n importPaths,\n options: { parallel, ...options },\n}: {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n options: IRunOptionsRuntime\n}): IRuntime {\n if (parallel > 0) {\n return new Coordinator({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n requireModules,\n requirePaths,\n importPaths,\n numberOfWorkers: parallel,\n })\n }\n return new Runtime({\n eventBroadcaster,\n eventDataCollector,\n newId,\n pickleIds,\n supportCodeLibrary,\n options,\n })\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
2
|
+
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
3
|
+
export declare function getSupportCodeLibrary({ cwd, newId, requireModules, requirePaths, importPaths, }: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
newId: IdGenerator.NewId;
|
|
6
|
+
requireModules: string[];
|
|
7
|
+
requirePaths: string[];
|
|
8
|
+
importPaths: string[];
|
|
9
|
+
}): Promise<ISupportCodeLibrary>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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.getSupportCodeLibrary = void 0;
|
|
7
|
+
const support_code_library_builder_1 = __importDefault(require("../support_code_library_builder"));
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const try_require_1 = __importDefault(require("../try_require"));
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
+
const { importer } = require('../importer');
|
|
12
|
+
async function getSupportCodeLibrary({ cwd, newId, requireModules, requirePaths, importPaths, }) {
|
|
13
|
+
support_code_library_builder_1.default.reset(cwd, newId, {
|
|
14
|
+
requireModules,
|
|
15
|
+
requirePaths,
|
|
16
|
+
importPaths,
|
|
17
|
+
});
|
|
18
|
+
requireModules.map((module) => (0, try_require_1.default)(module));
|
|
19
|
+
requirePaths.map((path) => (0, try_require_1.default)(path));
|
|
20
|
+
for (const path of importPaths) {
|
|
21
|
+
await importer((0, url_1.pathToFileURL)(path));
|
|
22
|
+
}
|
|
23
|
+
return support_code_library_builder_1.default.finalize();
|
|
24
|
+
}
|
|
25
|
+
exports.getSupportCodeLibrary = getSupportCodeLibrary;
|
|
26
|
+
//# sourceMappingURL=support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/api/support.ts"],"names":[],"mappings":";;;;;;AAEA,mGAAuE;AACvE,6BAAmC;AACnC,iEAAuC;AAEvC,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAEpC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,GAAG,EACH,KAAK,EACL,cAAc,EACd,YAAY,EACZ,WAAW,GAOZ;IACC,sCAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE;QAC1C,cAAc;QACd,YAAY;QACZ,WAAW;KACZ,CAAC,CAAA;IAEF,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC,CAAA;IAClD,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,CAAC,CAAA;IAE5C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;QAC9B,MAAM,QAAQ,CAAC,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,CAAA;KACpC;IAED,OAAO,sCAAyB,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AA3BD,sDA2BC","sourcesContent":["import { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { pathToFileURL } from 'url'\nimport tryRequire from '../try_require'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\nexport async function getSupportCodeLibrary({\n cwd,\n newId,\n requireModules,\n requirePaths,\n importPaths,\n}: {\n cwd: string\n newId: IdGenerator.NewId\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}): Promise<ISupportCodeLibrary> {\n supportCodeLibraryBuilder.reset(cwd, newId, {\n requireModules,\n requirePaths,\n importPaths,\n })\n\n requireModules.map((module) => tryRequire(module))\n requirePaths.map((path) => tryRequire(path))\n\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n\n return supportCodeLibraryBuilder.finalize()\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.teardownEnvironment = exports.setupEnvironment = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("mz/fs"));
|
|
9
|
+
const reindent_template_literals_1 = require("reindent-template-literals");
|
|
10
|
+
const stream_1 = require("stream");
|
|
11
|
+
const messages_1 = require("@cucumber/messages");
|
|
12
|
+
const newId = messages_1.IdGenerator.uuid();
|
|
13
|
+
async function setupEnvironment() {
|
|
14
|
+
const cwd = path_1.default.join(__dirname, '..', '..', 'tmp', `api_${newId()}`);
|
|
15
|
+
await fs_1.default.mkdir(path_1.default.join(cwd, 'features'), { recursive: true });
|
|
16
|
+
await fs_1.default.writeFile(path_1.default.join(cwd, 'features', 'test.feature'), (0, reindent_template_literals_1.reindent)(`Feature: test fixture
|
|
17
|
+
Scenario: one
|
|
18
|
+
Given a step
|
|
19
|
+
Then another step`));
|
|
20
|
+
await fs_1.default.writeFile(path_1.default.join(cwd, 'features', 'steps.ts'), (0, reindent_template_literals_1.reindent)(`import { Given, Then } from '../../../src'
|
|
21
|
+
Given('a step', function () {})
|
|
22
|
+
Then('another step', function () {})`));
|
|
23
|
+
await fs_1.default.writeFile(path_1.default.join(cwd, 'cucumber.mjs'), `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`);
|
|
24
|
+
const stdout = new stream_1.PassThrough();
|
|
25
|
+
return { cwd, stdout };
|
|
26
|
+
}
|
|
27
|
+
exports.setupEnvironment = setupEnvironment;
|
|
28
|
+
async function teardownEnvironment(environment) {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
fs_1.default.rm(environment.cwd, { recursive: true }, resolve);
|
|
31
|
+
}).then(() => {
|
|
32
|
+
environment.stdout.end();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.teardownEnvironment = teardownEnvironment;
|
|
36
|
+
//# sourceMappingURL=test_helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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A;IACtD,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC;AAND,kDAMC","sourcesContent":["import { IRunEnvironment } from './types'\nimport path from 'path'\nimport fs from 'mz/fs'\nimport { reindent } from 'reindent-template-literals'\nimport { PassThrough } from 'stream'\nimport { IdGenerator } from '@cucumber/messages'\n\nconst newId = IdGenerator.uuid()\n\nexport async function setupEnvironment(): Promise<Partial<IRunEnvironment>> {\n const cwd = path.join(__dirname, '..', '..', 'tmp', `api_${newId()}`)\n await fs.mkdir(path.join(cwd, 'features'), { recursive: true })\n await fs.writeFile(\n path.join(cwd, 'features', 'test.feature'),\n reindent(`Feature: test fixture\n Scenario: one\n Given a step\n Then another step`)\n )\n await fs.writeFile(\n path.join(cwd, 'features', 'steps.ts'),\n reindent(`import { Given, Then } from '../../../src'\n Given('a step', function () {})\n Then('another step', function () {})`)\n )\n await fs.writeFile(\n path.join(cwd, 'cucumber.mjs'),\n `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`\n )\n const stdout = new PassThrough()\n return { cwd, stdout }\n}\n\nexport async function teardownEnvironment(environment: IRunEnvironment) {\n return new Promise((resolve) => {\n fs.rm(environment.cwd, { recursive: true }, resolve)\n }).then(() => {\n environment.stdout.end()\n })\n}\n"]}
|