@cucumber/cucumber 10.0.1 → 10.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/environment.d.ts +6 -1
- package/lib/api/environment.js +6 -1
- package/lib/api/environment.js.map +1 -1
- package/lib/api/formatters.d.ts +2 -2
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/gherkin.d.ts +5 -13
- package/lib/api/gherkin.js +6 -26
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/index.d.ts +6 -2
- package/lib/api/index.js +4 -2
- package/lib/api/index.js.map +1 -1
- package/lib/api/load_configuration.d.ts +3 -3
- package/lib/api/load_configuration.js +7 -6
- package/lib/api/load_configuration.js.map +1 -1
- package/lib/api/load_sources.d.ts +4 -3
- package/lib/api/load_sources.js +20 -14
- package/lib/api/load_sources.js.map +1 -1
- package/lib/api/load_support.d.ts +4 -5
- package/lib/api/load_support.js +14 -9
- package/lib/api/load_support.js.map +1 -1
- package/lib/api/plugins.d.ts +4 -2
- package/lib/api/plugins.js +19 -8
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/run_cucumber.d.ts +5 -5
- package/lib/api/run_cucumber.js +32 -28
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/runtime.d.ts +2 -2
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/support.d.ts +2 -2
- package/lib/api/support.js.map +1 -1
- package/lib/api/types.d.ts +170 -26
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +4 -4
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/run.js +1 -2
- package/lib/cli/run.js.map +1 -1
- package/lib/configuration/check_schema.js +2 -2
- package/lib/configuration/check_schema.js.map +1 -1
- package/lib/configuration/types.d.ts +127 -10
- package/lib/configuration/types.js.map +1 -1
- package/lib/filter/filter_plugin.d.ts +3 -0
- package/lib/filter/filter_plugin.js +32 -0
- package/lib/filter/filter_plugin.js.map +1 -0
- package/lib/filter/index.d.ts +3 -0
- package/lib/filter/index.js +20 -0
- package/lib/filter/index.js.map +1 -0
- package/lib/filter/types.d.ts +14 -0
- package/lib/{models/pickle_order.js → filter/types.js} +1 -1
- package/lib/filter/types.js.map +1 -0
- package/lib/formatter/builder.d.ts +3 -3
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/index.d.ts +3 -7
- package/lib/formatter/index.js.map +1 -1
- package/lib/index.d.ts +15 -7
- package/lib/index.js +16 -7
- package/lib/index.js.map +1 -1
- package/lib/paths/index.d.ts +2 -0
- package/lib/paths/index.js +19 -0
- package/lib/paths/index.js.map +1 -0
- package/lib/paths/paths.d.ts +4 -0
- package/lib/{api → paths}/paths.js +8 -8
- package/lib/paths/paths.js.map +1 -0
- package/lib/paths/types.d.ts +6 -0
- package/lib/paths/types.js +3 -0
- package/lib/paths/types.js.map +1 -0
- package/lib/plugin/events.d.ts +2 -0
- package/lib/plugin/events.js +9 -0
- package/lib/plugin/events.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +5 -6
- package/lib/plugin/plugin_manager.js +26 -16
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +34 -10
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/index.d.ts +1 -0
- package/lib/publish/index.js +15 -0
- package/lib/publish/index.js.map +1 -1
- package/lib/publish/publish_plugin.d.ts +3 -2
- package/lib/publish/publish_plugin.js +27 -25
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/publish/types.d.ts +14 -0
- package/lib/publish/types.js +3 -0
- package/lib/publish/types.js.map +1 -0
- package/lib/runtime/assemble_test_cases.d.ts +2 -2
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/index.d.ts +4 -3
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +2 -2
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -2
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.js +1 -1
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +2 -1
- package/lib/runtime/run_test_run_hooks.js +3 -4
- package/lib/runtime/run_test_run_hooks.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +4 -3
- package/lib/runtime/test_case_runner.js +1 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +2 -2
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +7 -3
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/try_require.js +1 -3
- package/lib/try_require.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib/wrapper.mjs +2 -1
- package/package.json +23 -19
- package/lib/api/paths.d.ts +0 -8
- package/lib/api/paths.js.map +0 -1
- package/lib/models/pickle_order.d.ts +0 -1
- package/lib/models/pickle_order.js.map +0 -1
package/lib/api/run_cucumber.js
CHANGED
|
@@ -5,32 +5,37 @@ const node_events_1 = require("node:events");
|
|
|
5
5
|
const messages_1 = require("@cucumber/messages");
|
|
6
6
|
const helpers_1 = require("../formatter/helpers");
|
|
7
7
|
const helpers_2 = require("../cli/helpers");
|
|
8
|
-
const paths_1 = require("
|
|
8
|
+
const paths_1 = require("../paths");
|
|
9
9
|
const runtime_1 = require("./runtime");
|
|
10
10
|
const formatters_1 = require("./formatters");
|
|
11
11
|
const support_1 = require("./support");
|
|
12
12
|
const environment_1 = require("./environment");
|
|
13
13
|
const gherkin_1 = require("./gherkin");
|
|
14
14
|
const plugins_1 = require("./plugins");
|
|
15
|
-
const console_logger_1 = require("./console_logger");
|
|
16
15
|
/**
|
|
17
|
-
* Execute a Cucumber test run
|
|
16
|
+
* Execute a Cucumber test run and return the overall result
|
|
18
17
|
*
|
|
19
18
|
* @public
|
|
20
|
-
* @param
|
|
21
|
-
* @param environment - Project environment
|
|
22
|
-
* @param onMessage - Callback fired each time Cucumber emits a message
|
|
19
|
+
* @param options - Options for the run, obtainable via {@link loadConfiguration}
|
|
20
|
+
* @param environment - Project environment
|
|
21
|
+
* @param onMessage - Callback fired each time Cucumber emits a message
|
|
23
22
|
*/
|
|
24
|
-
async function runCucumber(
|
|
25
|
-
const
|
|
26
|
-
const
|
|
23
|
+
async function runCucumber(options, environment = {}, onMessage) {
|
|
24
|
+
const mergedEnvironment = (0, environment_1.mergeEnvironment)(environment);
|
|
25
|
+
const { cwd, stdout, stderr, env, logger } = mergedEnvironment;
|
|
27
26
|
const newId = messages_1.IdGenerator.uuid();
|
|
28
|
-
const supportCoordinates = '
|
|
29
|
-
?
|
|
30
|
-
:
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const supportCoordinates = 'originalCoordinates' in options.support
|
|
28
|
+
? options.support.originalCoordinates
|
|
29
|
+
: options.support;
|
|
30
|
+
const pluginManager = await (0, plugins_1.initializeForRunCucumber)(logger, {
|
|
31
|
+
...options,
|
|
32
|
+
support: supportCoordinates,
|
|
33
|
+
}, mergedEnvironment);
|
|
34
|
+
const resolvedPaths = await (0, paths_1.resolvePaths)(logger, cwd, options.sources, supportCoordinates);
|
|
35
|
+
pluginManager.emit('paths:resolve', resolvedPaths);
|
|
36
|
+
const { sourcePaths, requirePaths, importPaths } = resolvedPaths;
|
|
37
|
+
const supportCodeLibrary = 'originalCoordinates' in options.support
|
|
38
|
+
? options.support
|
|
34
39
|
: await (0, support_1.getSupportCodeLibrary)({
|
|
35
40
|
cwd,
|
|
36
41
|
newId,
|
|
@@ -38,12 +43,11 @@ async function runCucumber(configuration, environment = {}, onMessage) {
|
|
|
38
43
|
importPaths,
|
|
39
44
|
requireModules: supportCoordinates.requireModules,
|
|
40
45
|
});
|
|
41
|
-
const plugins = await (0, plugins_1.initializePlugins)(logger, configuration, environment);
|
|
42
46
|
const eventBroadcaster = new node_events_1.EventEmitter();
|
|
43
47
|
if (onMessage) {
|
|
44
48
|
eventBroadcaster.on('envelope', onMessage);
|
|
45
49
|
}
|
|
46
|
-
eventBroadcaster.on('envelope', (value) =>
|
|
50
|
+
eventBroadcaster.on('envelope', (value) => pluginManager.emit('message', value));
|
|
47
51
|
const eventDataCollector = new helpers_1.EventDataCollector(eventBroadcaster);
|
|
48
52
|
let formatterStreamError = false;
|
|
49
53
|
const cleanupFormatters = await (0, formatters_1.initializeFormatters)({
|
|
@@ -55,23 +59,23 @@ async function runCucumber(configuration, environment = {}, onMessage) {
|
|
|
55
59
|
onStreamError: () => (formatterStreamError = true),
|
|
56
60
|
eventBroadcaster,
|
|
57
61
|
eventDataCollector,
|
|
58
|
-
configuration:
|
|
62
|
+
configuration: options.formats,
|
|
59
63
|
supportCodeLibrary,
|
|
60
64
|
});
|
|
61
65
|
await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
|
|
62
66
|
let pickleIds = [];
|
|
63
67
|
let parseErrors = [];
|
|
64
|
-
if (
|
|
65
|
-
const gherkinResult = await (0, gherkin_1.
|
|
68
|
+
if (sourcePaths.length > 0) {
|
|
69
|
+
const gherkinResult = await (0, gherkin_1.getPicklesAndErrors)({
|
|
66
70
|
newId,
|
|
67
71
|
cwd,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
featurePaths,
|
|
71
|
-
coordinates: configuration.sources,
|
|
72
|
+
sourcePaths,
|
|
73
|
+
coordinates: options.sources,
|
|
72
74
|
onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),
|
|
73
75
|
});
|
|
74
|
-
|
|
76
|
+
const filteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);
|
|
77
|
+
const orderedPickles = await pluginManager.transform('pickles:order', filteredPickles);
|
|
78
|
+
pickleIds = orderedPickles.map(({ pickle }) => pickle.id);
|
|
75
79
|
parseErrors = gherkinResult.parseErrors;
|
|
76
80
|
}
|
|
77
81
|
if (parseErrors.length) {
|
|
@@ -79,7 +83,7 @@ async function runCucumber(configuration, environment = {}, onMessage) {
|
|
|
79
83
|
logger.error(`Parse error in "${parseError.source.uri}" ${parseError.message}`);
|
|
80
84
|
});
|
|
81
85
|
await cleanupFormatters();
|
|
82
|
-
await
|
|
86
|
+
await pluginManager.cleanup();
|
|
83
87
|
return {
|
|
84
88
|
success: false,
|
|
85
89
|
support: supportCodeLibrary,
|
|
@@ -101,11 +105,11 @@ async function runCucumber(configuration, environment = {}, onMessage) {
|
|
|
101
105
|
requireModules: supportCoordinates.requireModules,
|
|
102
106
|
requirePaths,
|
|
103
107
|
importPaths,
|
|
104
|
-
options:
|
|
108
|
+
options: options.runtime,
|
|
105
109
|
});
|
|
106
110
|
const success = await runtime.start();
|
|
107
111
|
await cleanupFormatters();
|
|
108
|
-
await
|
|
112
|
+
await pluginManager.cleanup();
|
|
109
113
|
return {
|
|
110
114
|
success: success && !formatterStreamError,
|
|
111
115
|
support: supportCodeLibrary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,iDAAsE;AACtE,kDAAyD;AACzD,4CAAyE;
|
|
1
|
+
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":"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","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { resolvePaths } from '../paths'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { mergeEnvironment } from './environment'\nimport { getPicklesAndErrors } from './gherkin'\nimport { initializeForRunCucumber } from './plugins'\n\n/**\n * Execute a Cucumber test run and return the overall result\n *\n * @public\n * @param options - Options for the run, obtainable via {@link loadConfiguration}\n * @param environment - Project environment\n * @param onMessage - Callback fired each time Cucumber emits a message\n */\nexport async function runCucumber(\n options: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const mergedEnvironment = mergeEnvironment(environment)\n const { cwd, stdout, stderr, env, logger } = mergedEnvironment\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'originalCoordinates' in options.support\n ? options.support.originalCoordinates\n : options.support\n\n const pluginManager = await initializeForRunCucumber(\n logger,\n {\n ...options,\n support: supportCoordinates,\n },\n mergedEnvironment\n )\n\n const resolvedPaths = await resolvePaths(\n logger,\n cwd,\n options.sources,\n supportCoordinates\n )\n pluginManager.emit('paths:resolve', resolvedPaths)\n const { sourcePaths, requirePaths, importPaths } = resolvedPaths\n\n const supportCodeLibrary =\n 'originalCoordinates' in options.support\n ? (options.support as SupportCodeLibrary)\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) =>\n pluginManager.emit('message', value)\n )\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: options.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (sourcePaths.length > 0) {\n const gherkinResult = await getPicklesAndErrors({\n newId,\n cwd,\n sourcePaths,\n coordinates: options.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n const filteredPickles = await pluginManager.transform(\n 'pickles:filter',\n gherkinResult.filterablePickles\n )\n const orderedPickles = await pluginManager.transform(\n 'pickles:order',\n filteredPickles\n )\n pickleIds = orderedPickles.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 pluginManager.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: options.runtime,\n })\n const success = await runtime.start()\n await cleanupFormatters()\n await pluginManager.cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
|
package/lib/api/runtime.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'node:events';
|
|
|
3
3
|
import { IdGenerator } from '@cucumber/messages';
|
|
4
4
|
import { IRuntime } from '../runtime';
|
|
5
5
|
import { EventDataCollector } from '../formatter/helpers';
|
|
6
|
-
import {
|
|
6
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
7
|
import { ILogger } from '../logger';
|
|
8
8
|
import { IRunOptionsRuntime } from './types';
|
|
9
9
|
export declare function makeRuntime({ cwd, logger, eventBroadcaster, eventDataCollector, pickleIds, newId, supportCodeLibrary, requireModules, requirePaths, importPaths, options: { parallel, ...options }, }: {
|
|
@@ -13,7 +13,7 @@ export declare function makeRuntime({ cwd, logger, eventBroadcaster, eventDataCo
|
|
|
13
13
|
eventDataCollector: EventDataCollector;
|
|
14
14
|
newId: IdGenerator.NewId;
|
|
15
15
|
pickleIds: string[];
|
|
16
|
-
supportCodeLibrary:
|
|
16
|
+
supportCodeLibrary: SupportCodeLibrary;
|
|
17
17
|
requireModules: string[];
|
|
18
18
|
requirePaths: string[];
|
|
19
19
|
importPaths: string[];
|
package/lib/api/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":";;;;;;AAEA,yDAA8C;AAG9C,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 { EventEmitter } from 'node:events'\nimport { IdGenerator } from '@cucumber/messages'\nimport Runtime, { IRuntime } from '../runtime'\nimport { EventDataCollector } from '../formatter/helpers'\nimport {
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/api/runtime.ts"],"names":[],"mappings":";;;;;;AAEA,yDAA8C;AAG9C,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 { EventEmitter } from 'node:events'\nimport { IdGenerator } from '@cucumber/messages'\nimport Runtime, { IRuntime } from '../runtime'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport Coordinator from '../runtime/parallel/coordinator'\nimport { ILogger } from '../logger'\nimport { IRunOptionsRuntime } from './types'\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: SupportCodeLibrary\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"]}
|
package/lib/api/support.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IdGenerator } from '@cucumber/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
3
3
|
export declare function getSupportCodeLibrary({ cwd, newId, requireModules, requirePaths, importPaths, }: {
|
|
4
4
|
cwd: string;
|
|
5
5
|
newId: IdGenerator.NewId;
|
|
6
6
|
requireModules: string[];
|
|
7
7
|
requirePaths: string[];
|
|
8
8
|
importPaths: string[];
|
|
9
|
-
}): Promise<
|
|
9
|
+
}): Promise<SupportCodeLibrary>;
|
package/lib/api/support.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/api/support.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AAGxC,mGAAuE;AACvE,iEAAuC;AAEhC,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,MAAM,CAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;KAC7C;IAED,OAAO,sCAAyB,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AA3BD,sDA2BC","sourcesContent":["import { pathToFileURL } from 'node:url'\nimport { IdGenerator } from '@cucumber/messages'\nimport {
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/api/support.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AAGxC,mGAAuE;AACvE,iEAAuC;AAEhC,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,MAAM,CAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;KAC7C;IAED,OAAO,sCAAyB,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AA3BD,sDA2BC","sourcesContent":["import { pathToFileURL } from 'node:url'\nimport { IdGenerator } from '@cucumber/messages'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport tryRequire from '../try_require'\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<SupportCodeLibrary> {\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 import(pathToFileURL(path).toString())\n }\n\n return supportCodeLibraryBuilder.finalize()\n}\n"]}
|
package/lib/api/types.d.ts
CHANGED
|
@@ -1,55 +1,84 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { PickleOrder } from '../models/pickle_order';
|
|
7
|
-
import { IRuntimeOptions } from '../runtime';
|
|
4
|
+
import { JsonObject } from 'type-fest';
|
|
5
|
+
import { IPublishConfig } from '../publish';
|
|
8
6
|
import { IConfiguration } from '../configuration';
|
|
7
|
+
import { IPickleOrder } from '../filter';
|
|
9
8
|
/**
|
|
9
|
+
* Options for {@link loadConfiguration}
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export interface ILoadConfigurationOptions {
|
|
13
13
|
/**
|
|
14
|
-
* Path to load configuration file from
|
|
14
|
+
* Path to load configuration file from, or `false` to skip
|
|
15
|
+
* @default `cucumber.(json|yaml|yml|js|cjs|mjs)`
|
|
15
16
|
*/
|
|
16
|
-
file?: string;
|
|
17
|
+
file?: string | false;
|
|
17
18
|
/**
|
|
18
|
-
* Zero or more profile names from which to source configuration
|
|
19
|
+
* Zero or more profile names from which to source configuration in the file
|
|
20
|
+
* @remarks
|
|
21
|
+
* If omitted or empty, the `default` profile will be used.
|
|
19
22
|
*/
|
|
20
23
|
profiles?: string[];
|
|
21
24
|
/**
|
|
22
|
-
* Ad-hoc configuration options to be
|
|
25
|
+
* Ad-hoc configuration options to be merged over the top of whatever is
|
|
26
|
+
* loaded from the configuration file/profiles
|
|
23
27
|
*/
|
|
24
28
|
provided?: Partial<IConfiguration>;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
31
|
+
* Response from {@link loadConfiguration}
|
|
27
32
|
* @public
|
|
28
33
|
*/
|
|
29
34
|
export interface IResolvedConfiguration {
|
|
30
35
|
/**
|
|
31
|
-
* The final flat configuration object resolved from the configuration
|
|
36
|
+
* The final flat configuration object resolved from the configuration
|
|
37
|
+
* file/profiles plus any extra provided
|
|
32
38
|
*/
|
|
33
39
|
useConfiguration: IConfiguration;
|
|
34
40
|
/**
|
|
35
|
-
* The format that can be passed into
|
|
41
|
+
* The format that can be passed into {@link runCucumber}
|
|
36
42
|
*/
|
|
37
43
|
runConfiguration: IRunConfiguration;
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
46
|
+
* Options relating to sources (i.e. feature files) - where to load them from,
|
|
47
|
+
* how to interpret, filter and order them
|
|
40
48
|
* @public
|
|
41
49
|
*/
|
|
42
50
|
export interface ISourcesCoordinates {
|
|
51
|
+
/**
|
|
52
|
+
* Default Gherkin dialect
|
|
53
|
+
* @remarks
|
|
54
|
+
* Used if no dialect is specified in the feature file itself.
|
|
55
|
+
*/
|
|
43
56
|
defaultDialect: string;
|
|
57
|
+
/**
|
|
58
|
+
* Paths and/or glob expressions to feature files
|
|
59
|
+
*/
|
|
44
60
|
paths: string[];
|
|
61
|
+
/**
|
|
62
|
+
* Regular expressions of which scenario names should match one of to be run
|
|
63
|
+
*/
|
|
45
64
|
names: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Tag expression to filter which scenarios should be run
|
|
67
|
+
*/
|
|
46
68
|
tagExpression: string;
|
|
47
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Run in the order defined, or in a random order
|
|
71
|
+
*/
|
|
72
|
+
order: IPickleOrder;
|
|
48
73
|
}
|
|
49
74
|
/**
|
|
75
|
+
* A pickle that has been successfully compiled from a source
|
|
50
76
|
* @public
|
|
51
77
|
*/
|
|
52
78
|
export interface IPlannedPickle {
|
|
79
|
+
/**
|
|
80
|
+
* Name of the pickle (after parameter resolution)
|
|
81
|
+
*/
|
|
53
82
|
name: string;
|
|
54
83
|
uri: string;
|
|
55
84
|
location: {
|
|
@@ -58,6 +87,7 @@ export interface IPlannedPickle {
|
|
|
58
87
|
};
|
|
59
88
|
}
|
|
60
89
|
/**
|
|
90
|
+
* An error encountered when parsing a source
|
|
61
91
|
* @public
|
|
62
92
|
*/
|
|
63
93
|
export interface ISourcesError {
|
|
@@ -66,46 +96,133 @@ export interface ISourcesError {
|
|
|
66
96
|
line: number;
|
|
67
97
|
column?: number;
|
|
68
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Error message explaining what went wrong with the parse
|
|
101
|
+
*/
|
|
69
102
|
message: string;
|
|
70
103
|
}
|
|
71
104
|
/**
|
|
105
|
+
* Response from {@link loadSources}
|
|
72
106
|
* @public
|
|
73
107
|
*/
|
|
74
108
|
export interface ILoadSourcesResult {
|
|
109
|
+
/**
|
|
110
|
+
* Pickles that have been successfully compiled, in the order they would be
|
|
111
|
+
* run in
|
|
112
|
+
*/
|
|
75
113
|
plan: IPlannedPickle[];
|
|
114
|
+
/**
|
|
115
|
+
* Any errors encountered when parsing sources
|
|
116
|
+
*/
|
|
76
117
|
errors: ISourcesError[];
|
|
77
118
|
}
|
|
78
119
|
/**
|
|
120
|
+
* Options relating to user code (aka support code) - where to load it from and
|
|
121
|
+
* how to preprocess it
|
|
79
122
|
* @public
|
|
80
123
|
*/
|
|
81
124
|
export interface ISupportCodeCoordinates {
|
|
125
|
+
/**
|
|
126
|
+
* Names of transpilation modules to load, via `require()`
|
|
127
|
+
*/
|
|
82
128
|
requireModules: string[];
|
|
129
|
+
/**
|
|
130
|
+
* Paths and/or glob expressions of user code to load, via `require()`
|
|
131
|
+
*/
|
|
83
132
|
requirePaths: string[];
|
|
133
|
+
/**
|
|
134
|
+
* Paths and/or glob expressions of user code to load, via `import()`
|
|
135
|
+
*/
|
|
84
136
|
importPaths: string[];
|
|
85
137
|
}
|
|
86
138
|
/**
|
|
139
|
+
* Options for {@link loadSupport}
|
|
87
140
|
* @public
|
|
141
|
+
* @remarks
|
|
142
|
+
* A subset of {@link IRunConfiguration}
|
|
88
143
|
*/
|
|
89
144
|
export interface ILoadSupportOptions {
|
|
145
|
+
/**
|
|
146
|
+
* @remarks
|
|
147
|
+
* This is needed because the default support path locations are derived from
|
|
148
|
+
* feature file locations.
|
|
149
|
+
*/
|
|
90
150
|
sources: ISourcesCoordinates;
|
|
91
151
|
support: ISupportCodeCoordinates;
|
|
92
152
|
}
|
|
93
153
|
/**
|
|
154
|
+
* Options relating to behaviour when actually running tests
|
|
94
155
|
* @public
|
|
95
156
|
*/
|
|
96
|
-
export interface IRunOptionsRuntime
|
|
157
|
+
export interface IRunOptionsRuntime {
|
|
158
|
+
/**
|
|
159
|
+
* Perform a dry run, where a test run is prepared but nothing is executed
|
|
160
|
+
*/
|
|
161
|
+
dryRun: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Stop running tests when a test fails
|
|
164
|
+
*/
|
|
165
|
+
failFast: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Filter out stack frames from Cucumber's code when formatting stack traces
|
|
168
|
+
*/
|
|
169
|
+
filterStacktraces: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Run tests in parallel with the given number of worker processes
|
|
172
|
+
*/
|
|
97
173
|
parallel: number;
|
|
174
|
+
/**
|
|
175
|
+
* Retry failing tests up to the given number of times
|
|
176
|
+
*/
|
|
177
|
+
retry: number;
|
|
178
|
+
/**
|
|
179
|
+
* Tag expression to filter which scenarios can be retried
|
|
180
|
+
*/
|
|
181
|
+
retryTagFilter: string;
|
|
182
|
+
/**
|
|
183
|
+
* Fail the test run if there are pending steps
|
|
184
|
+
*/
|
|
185
|
+
strict: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Parameters to be passed to the World
|
|
188
|
+
* @remarks
|
|
189
|
+
* The value must be a JSON-serializable object.
|
|
190
|
+
*/
|
|
191
|
+
worldParameters: JsonObject;
|
|
98
192
|
}
|
|
99
193
|
/**
|
|
194
|
+
* Options relating to formatters - which ones to use, where to write their
|
|
195
|
+
* output, how they should behave
|
|
100
196
|
* @public
|
|
101
197
|
*/
|
|
102
198
|
export interface IRunOptionsFormats {
|
|
199
|
+
/**
|
|
200
|
+
* Name/path of the formatter to use for `stdout` output
|
|
201
|
+
*/
|
|
103
202
|
stdout: string;
|
|
203
|
+
/**
|
|
204
|
+
* Zero or more mappings of file output path (key) to name/path of the
|
|
205
|
+
* formatter to use (value)
|
|
206
|
+
* @example
|
|
207
|
+
* \{
|
|
208
|
+
* "./reports/cucumber.html": "html",
|
|
209
|
+
* "./reports/custom.txt": "./custom-formatter.js"
|
|
210
|
+
* \}
|
|
211
|
+
*/
|
|
104
212
|
files: Record<string, string>;
|
|
213
|
+
/**
|
|
214
|
+
* Options for report publication, or `false` to disable publication
|
|
215
|
+
*/
|
|
105
216
|
publish: IPublishConfig | false;
|
|
106
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Options to be provided to formatters
|
|
219
|
+
* @remarks
|
|
220
|
+
* The value must be a JSON-serializable object.
|
|
221
|
+
*/
|
|
222
|
+
options: JsonObject;
|
|
107
223
|
}
|
|
108
224
|
/**
|
|
225
|
+
* Structured configuration object suitable for passing to {@link runCucumber}
|
|
109
226
|
* @public
|
|
110
227
|
*/
|
|
111
228
|
export interface IRunConfiguration {
|
|
@@ -115,14 +232,32 @@ export interface IRunConfiguration {
|
|
|
115
232
|
formats: IRunOptionsFormats;
|
|
116
233
|
}
|
|
117
234
|
/**
|
|
235
|
+
* A collection of user-defined code and setup ("support code") that can be
|
|
236
|
+
* used for a test run
|
|
118
237
|
* @public
|
|
238
|
+
* @remarks
|
|
239
|
+
* This is mostly a marker interface. The actual instance is a complex object
|
|
240
|
+
* that you shouldn't interact with directly, but some functions return and/or
|
|
241
|
+
* accept it as a means of optimising a test workflow.
|
|
119
242
|
*/
|
|
120
|
-
export
|
|
243
|
+
export interface ISupportCodeLibrary {
|
|
244
|
+
readonly originalCoordinates: ISupportCodeCoordinates;
|
|
245
|
+
}
|
|
121
246
|
/**
|
|
247
|
+
* Either an actual {@link ISupportCodeLibrary | support code library}, or the
|
|
248
|
+
* {@link ISupportCodeCoordinates | coordinates} required to create and
|
|
249
|
+
* populate one
|
|
122
250
|
* @public
|
|
251
|
+
* @remarks
|
|
252
|
+
* This alias exists because {@link runCucumber} will accept an existing
|
|
253
|
+
* support code library in its options and thus avoid trying to load it again,
|
|
254
|
+
* improving performance and avoiding cache issues for use cases where multiple
|
|
255
|
+
* test runs happen within the same process. Note this is only useful in serial
|
|
256
|
+
* mode, as parallel workers will each load the support code themselves anyway.
|
|
123
257
|
*/
|
|
124
|
-
export type
|
|
258
|
+
export type ISupportCodeCoordinatesOrLibrary = ISupportCodeCoordinates | ISupportCodeLibrary;
|
|
125
259
|
/**
|
|
260
|
+
* Options for {@link runCucumber}
|
|
126
261
|
* @public
|
|
127
262
|
*/
|
|
128
263
|
export interface IRunOptions {
|
|
@@ -132,44 +267,53 @@ export interface IRunOptions {
|
|
|
132
267
|
formats: IRunOptionsFormats;
|
|
133
268
|
}
|
|
134
269
|
/**
|
|
135
|
-
* Contextual data about the project environment
|
|
136
|
-
*
|
|
270
|
+
* Contextual data about the project environment
|
|
137
271
|
* @public
|
|
138
272
|
*/
|
|
139
273
|
export interface IRunEnvironment {
|
|
140
274
|
/**
|
|
141
|
-
* Working directory for the project
|
|
275
|
+
* Working directory for the project
|
|
276
|
+
* @default process.cwd()
|
|
142
277
|
*/
|
|
143
278
|
cwd?: string;
|
|
144
279
|
/**
|
|
145
|
-
* Writable stream where the test run's main output is written
|
|
280
|
+
* Writable stream where the test run's main formatter output is written
|
|
281
|
+
* @default process.stdout
|
|
146
282
|
*/
|
|
147
283
|
stdout?: Writable;
|
|
148
284
|
/**
|
|
149
|
-
* Writable stream where the test run's warning/error output is written
|
|
285
|
+
* Writable stream where the test run's warning/error output is written
|
|
286
|
+
* @default process.stderr
|
|
150
287
|
*/
|
|
151
288
|
stderr?: Writable;
|
|
152
289
|
/**
|
|
153
|
-
* Environment variables
|
|
290
|
+
* Environment variables
|
|
291
|
+
* @default process.env
|
|
154
292
|
*/
|
|
155
293
|
env?: NodeJS.ProcessEnv;
|
|
156
294
|
/**
|
|
157
|
-
* Whether debug logging
|
|
295
|
+
* Whether debug logging should be emitted to {@link IRunEnvironment.stderr}
|
|
296
|
+
* @default false
|
|
297
|
+
* @see {@link https://github.com/cucumber/cucumber-js/blob/main/docs/debugging.md}
|
|
158
298
|
*/
|
|
159
299
|
debug?: boolean;
|
|
160
300
|
}
|
|
161
301
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
302
|
+
* Response from {@link runCucumber}
|
|
164
303
|
* @public
|
|
165
304
|
*/
|
|
166
305
|
export interface IRunResult {
|
|
167
306
|
/**
|
|
168
|
-
* Whether the test run was overall successful
|
|
307
|
+
* Whether the test run was overall successful
|
|
308
|
+
* @remarks
|
|
309
|
+
* The exact meaning can vary based on the `strict` configuration option.
|
|
169
310
|
*/
|
|
170
311
|
success: boolean;
|
|
171
312
|
/**
|
|
172
|
-
* The support code library that was used in the test run
|
|
313
|
+
* The support code library that was used in the test run
|
|
314
|
+
* @remarks
|
|
315
|
+
* This can be reused in subsequent {@link runCucumber} calls,
|
|
316
|
+
* see {@link ISupportCodeCoordinatesOrLibrary}
|
|
173
317
|
*/
|
|
174
318
|
support: ISupportCodeLibrary;
|
|
175
319
|
}
|
package/lib/api/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\nimport { JsonObject } from 'type-fest'\nimport { IPublishConfig } from '../publish'\nimport { IConfiguration } from '../configuration'\nimport { IPickleOrder } from '../filter'\n\n/**\n * Options for {@link loadConfiguration}\n * @public\n */\nexport interface ILoadConfigurationOptions {\n /**\n * Path to load configuration file from, or `false` to skip\n * @default `cucumber.(json|yaml|yml|js|cjs|mjs)`\n */\n file?: string | false\n /**\n * Zero or more profile names from which to source configuration in the file\n * @remarks\n * If omitted or empty, the `default` profile will be used.\n */\n profiles?: string[]\n /**\n * Ad-hoc configuration options to be merged over the top of whatever is\n * loaded from the configuration file/profiles\n */\n provided?: Partial<IConfiguration>\n}\n\n/**\n * Response from {@link loadConfiguration}\n * @public\n */\nexport interface IResolvedConfiguration {\n /**\n * The final flat configuration object resolved from the configuration\n * file/profiles plus any extra provided\n */\n useConfiguration: IConfiguration\n /**\n * The format that can be passed into {@link runCucumber}\n */\n runConfiguration: IRunConfiguration\n}\n\n/**\n * Options relating to sources (i.e. feature files) - where to load them from,\n * how to interpret, filter and order them\n * @public\n */\nexport interface ISourcesCoordinates {\n /**\n * Default Gherkin dialect\n * @remarks\n * Used if no dialect is specified in the feature file itself.\n */\n defaultDialect: string\n /**\n * Paths and/or glob expressions to feature files\n */\n paths: string[]\n /**\n * Regular expressions of which scenario names should match one of to be run\n */\n names: string[]\n /**\n * Tag expression to filter which scenarios should be run\n */\n tagExpression: string\n /**\n * Run in the order defined, or in a random order\n */\n order: IPickleOrder\n}\n\n/**\n * A pickle that has been successfully compiled from a source\n * @public\n */\nexport interface IPlannedPickle {\n /**\n * Name of the pickle (after parameter resolution)\n */\n name: string\n uri: string\n location: {\n line: number\n column?: number\n }\n}\n\n/**\n * An error encountered when parsing a source\n * @public\n */\nexport interface ISourcesError {\n uri: string\n location: {\n line: number\n column?: number\n }\n /**\n * Error message explaining what went wrong with the parse\n */\n message: string\n}\n\n/**\n * Response from {@link loadSources}\n * @public\n */\nexport interface ILoadSourcesResult {\n /**\n * Pickles that have been successfully compiled, in the order they would be\n * run in\n */\n plan: IPlannedPickle[]\n /**\n * Any errors encountered when parsing sources\n */\n errors: ISourcesError[]\n}\n\n/**\n * Options relating to user code (aka support code) - where to load it from and\n * how to preprocess it\n * @public\n */\nexport interface ISupportCodeCoordinates {\n /**\n * Names of transpilation modules to load, via `require()`\n */\n requireModules: string[]\n /**\n * Paths and/or glob expressions of user code to load, via `require()`\n */\n requirePaths: string[]\n /**\n * Paths and/or glob expressions of user code to load, via `import()`\n */\n importPaths: string[]\n}\n\n/**\n * Options for {@link loadSupport}\n * @public\n * @remarks\n * A subset of {@link IRunConfiguration}\n */\nexport interface ILoadSupportOptions {\n /**\n * @remarks\n * This is needed because the default support path locations are derived from\n * feature file locations.\n */\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n}\n\n/**\n * Options relating to behaviour when actually running tests\n * @public\n */\nexport interface IRunOptionsRuntime {\n /**\n * Perform a dry run, where a test run is prepared but nothing is executed\n */\n dryRun: boolean\n /**\n * Stop running tests when a test fails\n */\n failFast: boolean\n /**\n * Filter out stack frames from Cucumber's code when formatting stack traces\n */\n filterStacktraces: boolean\n /**\n * Run tests in parallel with the given number of worker processes\n */\n parallel: number\n /**\n * Retry failing tests up to the given number of times\n */\n retry: number\n /**\n * Tag expression to filter which scenarios can be retried\n */\n retryTagFilter: string\n /**\n * Fail the test run if there are pending steps\n */\n strict: boolean\n /**\n * Parameters to be passed to the World\n * @remarks\n * The value must be a JSON-serializable object.\n */\n worldParameters: JsonObject\n}\n\n/**\n * Options relating to formatters - which ones to use, where to write their\n * output, how they should behave\n * @public\n */\nexport interface IRunOptionsFormats {\n /**\n * Name/path of the formatter to use for `stdout` output\n */\n stdout: string\n /**\n * Zero or more mappings of file output path (key) to name/path of the\n * formatter to use (value)\n * @example\n * \\{\n * \"./reports/cucumber.html\": \"html\",\n * \"./reports/custom.txt\": \"./custom-formatter.js\"\n * \\}\n */\n files: Record<string, string>\n /**\n * Options for report publication, or `false` to disable publication\n */\n publish: IPublishConfig | false\n /**\n * Options to be provided to formatters\n * @remarks\n * The value must be a JSON-serializable object.\n */\n options: JsonObject\n}\n\n/**\n * Structured configuration object suitable for passing to {@link runCucumber}\n * @public\n */\nexport interface IRunConfiguration {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * A collection of user-defined code and setup (\"support code\") that can be\n * used for a test run\n * @public\n * @remarks\n * This is mostly a marker interface. The actual instance is a complex object\n * that you shouldn't interact with directly, but some functions return and/or\n * accept it as a means of optimising a test workflow.\n */\nexport interface ISupportCodeLibrary {\n readonly originalCoordinates: ISupportCodeCoordinates\n}\n\n/**\n * Either an actual {@link ISupportCodeLibrary | support code library}, or the\n * {@link ISupportCodeCoordinates | coordinates} required to create and\n * populate one\n * @public\n * @remarks\n * This alias exists because {@link runCucumber} will accept an existing\n * support code library in its options and thus avoid trying to load it again,\n * improving performance and avoiding cache issues for use cases where multiple\n * test runs happen within the same process. Note this is only useful in serial\n * mode, as parallel workers will each load the support code themselves anyway.\n */\nexport type ISupportCodeCoordinatesOrLibrary =\n | ISupportCodeCoordinates\n | ISupportCodeLibrary\n\n/**\n * Options for {@link runCucumber}\n * @public\n */\nexport interface IRunOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinatesOrLibrary\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * Contextual data about the project environment\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project\n * @default process.cwd()\n */\n cwd?: string\n /**\n * Writable stream where the test run's main formatter output is written\n * @default process.stdout\n */\n stdout?: Writable\n /**\n * Writable stream where the test run's warning/error output is written\n * @default process.stderr\n */\n stderr?: Writable\n /**\n * Environment variables\n * @default process.env\n */\n env?: NodeJS.ProcessEnv\n /**\n * Whether debug logging should be emitted to {@link IRunEnvironment.stderr}\n * @default false\n * @see {@link https://github.com/cucumber/cucumber-js/blob/main/docs/debugging.md}\n */\n debug?: boolean\n}\n\n/**\n * Response from {@link runCucumber}\n * @public\n */\nexport interface IRunResult {\n /**\n * Whether the test run was overall successful\n * @remarks\n * The exact meaning can vary based on the `strict` configuration option.\n */\n success: boolean\n /**\n * The support code library that was used in the test run\n * @remarks\n * This can be reused in subsequent {@link runCucumber} calls,\n * see {@link ISupportCodeCoordinatesOrLibrary}\n */\n support: ISupportCodeLibrary\n}\n"]}
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { Readable } from 'node:stream';
|
|
|
6
6
|
import { IdGenerator } from '@cucumber/messages';
|
|
7
7
|
import { EventDataCollector } from '../formatter/helpers';
|
|
8
8
|
import PickleFilter from '../pickle_filter';
|
|
9
|
-
import {
|
|
10
|
-
import { PickleOrder } from '../models/pickle_order';
|
|
9
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
11
10
|
import { ILogger } from '../logger';
|
|
11
|
+
import { IPickleOrder } from '../filter';
|
|
12
12
|
interface IParseGherkinMessageStreamRequest {
|
|
13
13
|
cwd?: string;
|
|
14
14
|
eventBroadcaster: EventEmitter;
|
|
@@ -27,11 +27,11 @@ interface IParseGherkinMessageStreamRequest {
|
|
|
27
27
|
* @param pickleFilter
|
|
28
28
|
*/
|
|
29
29
|
export declare function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }: IParseGherkinMessageStreamRequest): Promise<string[]>;
|
|
30
|
-
export declare function orderPickles<T = string>(pickleIds: T[], order:
|
|
30
|
+
export declare function orderPickles<T = string>(pickleIds: T[], order: IPickleOrder, logger: ILogger): void;
|
|
31
31
|
export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv): Promise<void>;
|
|
32
32
|
export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
|
|
33
33
|
eventBroadcaster: EventEmitter;
|
|
34
|
-
supportCodeLibrary:
|
|
34
|
+
supportCodeLibrary: SupportCodeLibrary;
|
|
35
35
|
newId: IdGenerator.NewId;
|
|
36
36
|
}): void;
|
|
37
37
|
export {};
|