@cucumber/cucumber 10.9.0 → 11.0.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/run_cucumber.js +8 -10
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/{runtime → assemble}/assemble_test_cases.d.ts +4 -6
- package/lib/{runtime → assemble}/assemble_test_cases.js +9 -8
- package/lib/assemble/assemble_test_cases.js.map +1 -0
- package/lib/assemble/index.d.ts +2 -0
- package/lib/assemble/index.js +19 -0
- package/lib/assemble/index.js.map +1 -0
- package/lib/assemble/types.d.ts +10 -0
- package/lib/{runtime/parallel/command_types.js → assemble/types.js} +1 -1
- package/lib/assemble/types.js.map +1 -0
- package/lib/cli/helpers.d.ts +0 -23
- package/lib/cli/helpers.js +1 -33
- package/lib/cli/helpers.js.map +1 -1
- package/lib/index.d.ts +0 -16
- package/lib/index.js +1 -16
- package/lib/index.js.map +1 -1
- package/lib/runtime/coordinator.d.ts +16 -0
- package/lib/runtime/coordinator.js +42 -0
- package/lib/runtime/coordinator.js.map +1 -0
- package/lib/runtime/helpers.d.ts +3 -3
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +2 -41
- package/lib/runtime/index.js +14 -81
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/make_runtime.d.ts +17 -0
- package/lib/runtime/make_runtime.js +14 -0
- package/lib/runtime/make_runtime.js.map +1 -0
- package/lib/runtime/parallel/adapter.d.ts +48 -0
- package/lib/runtime/parallel/adapter.js +152 -0
- package/lib/runtime/parallel/adapter.js.map +1 -0
- package/lib/runtime/parallel/run_worker.js +2 -5
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/types.d.ts +32 -0
- package/lib/runtime/parallel/types.js +3 -0
- package/lib/runtime/parallel/types.js.map +1 -0
- package/lib/runtime/parallel/worker.d.ts +8 -9
- package/lib/runtime/parallel/worker.js +28 -44
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/serial/adapter.d.ts +13 -0
- package/lib/runtime/serial/adapter.js +24 -0
- package/lib/runtime/serial/adapter.js.map +1 -0
- package/lib/runtime/stopwatch.d.ts +2 -2
- package/lib/runtime/stopwatch.js +3 -4
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +1 -4
- package/lib/runtime/test_case_runner.js +6 -7
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/runtime/types.d.ts +17 -0
- package/lib/runtime/types.js +3 -0
- package/lib/runtime/types.js.map +1 -0
- package/lib/runtime/worker.d.ts +18 -0
- package/lib/runtime/worker.js +57 -0
- package/lib/runtime/worker.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +2 -3
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +5 -0
- package/lib/support_code_library_builder/types.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 +1 -3
- package/package.json +4 -4
- package/lib/api/runtime.d.ts +0 -18
- package/lib/api/runtime.js +0 -33
- package/lib/api/runtime.js.map +0 -1
- package/lib/runtime/assemble_test_cases.js.map +0 -1
- package/lib/runtime/parallel/command_types.d.ts +0 -31
- package/lib/runtime/parallel/command_types.js.map +0 -1
- package/lib/runtime/parallel/coordinator.d.ts +0 -66
- package/lib/runtime/parallel/coordinator.js +0 -209
- package/lib/runtime/parallel/coordinator.js.map +0 -1
package/lib/api/run_cucumber.js
CHANGED
|
@@ -7,7 +7,7 @@ const helpers_1 = require("../formatter/helpers");
|
|
|
7
7
|
const helpers_2 = require("../cli/helpers");
|
|
8
8
|
const paths_1 = require("../paths");
|
|
9
9
|
const version_1 = require("../version");
|
|
10
|
-
const runtime_1 = require("
|
|
10
|
+
const runtime_1 = require("../runtime");
|
|
11
11
|
const formatters_1 = require("./formatters");
|
|
12
12
|
const support_1 = require("./support");
|
|
13
13
|
const environment_1 = require("./environment");
|
|
@@ -76,7 +76,7 @@ Running from: ${__dirname}
|
|
|
76
76
|
pluginManager,
|
|
77
77
|
});
|
|
78
78
|
await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
|
|
79
|
-
let
|
|
79
|
+
let filteredPickles = [];
|
|
80
80
|
let parseErrors = [];
|
|
81
81
|
if (sourcePaths.length > 0) {
|
|
82
82
|
const gherkinResult = await (0, gherkin_1.getPicklesAndErrors)({
|
|
@@ -86,9 +86,8 @@ Running from: ${__dirname}
|
|
|
86
86
|
coordinates: options.sources,
|
|
87
87
|
onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),
|
|
88
88
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
pickleIds = orderedPickles.map(({ pickle }) => pickle.id);
|
|
89
|
+
filteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);
|
|
90
|
+
filteredPickles = await pluginManager.transform('pickles:order', filteredPickles);
|
|
92
91
|
parseErrors = gherkinResult.parseErrors;
|
|
93
92
|
}
|
|
94
93
|
if (parseErrors.length) {
|
|
@@ -107,17 +106,16 @@ Running from: ${__dirname}
|
|
|
107
106
|
supportCodeLibrary,
|
|
108
107
|
newId,
|
|
109
108
|
});
|
|
110
|
-
const runtime = (0, runtime_1.makeRuntime)({
|
|
111
|
-
|
|
109
|
+
const runtime = await (0, runtime_1.makeRuntime)({
|
|
110
|
+
environment,
|
|
112
111
|
logger,
|
|
113
112
|
eventBroadcaster,
|
|
114
|
-
|
|
115
|
-
pickleIds,
|
|
113
|
+
sourcedPickles: filteredPickles,
|
|
116
114
|
newId,
|
|
117
115
|
supportCodeLibrary,
|
|
118
116
|
options: options.runtime,
|
|
119
117
|
});
|
|
120
|
-
const success = await runtime.
|
|
118
|
+
const success = await runtime.run();
|
|
121
119
|
await pluginManager.cleanup();
|
|
122
120
|
await cleanupFormatters();
|
|
123
121
|
return {
|
|
@@ -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;AACzE,oCAAuC;AAEvC,wCAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,iDAAsE;AACtE,kDAAyD;AACzD,4CAAyE;AACzE,oCAAuC;AAEvC,wCAAoC;AAEpC,wCAAwC;AAExC,6CAAmD;AACnD,uCAAiD;AACjD,+CAAgD;AAChD,uCAA+C;AAC/C,uCAAoD;AAEpD;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAoB,EACpB,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,iBAAiB,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAA;IAE9D,MAAM,CAAC,KAAK,CAAC,uBAAuB,iBAAO;qBACxB,GAAG;gBACR,SAAS;CACxB,CAAC,CAAA;IAEA,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;IAEhC,MAAM,kBAAkB,GACtB,qBAAqB,IAAI,OAAO,CAAC,OAAO;QACtC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB;QACrC,CAAC,CAAC,MAAM,CAAC,MAAM,CACX;YACE,cAAc,EAAE,EAAE;YAClB,YAAY,EAAE,EAAE;YAChB,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;SAChB,EACD,OAAO,CAAC,OAAO,CAChB,CAAA;IAEP,MAAM,aAAa,GAAG,MAAM,IAAA,kCAAwB,EAClD,MAAM,EACN;QACE,GAAG,OAAO;QACV,OAAO,EAAE,kBAAkB;KAC5B,EACD,iBAAiB,CA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OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAA;IACnC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAA;IAC7B,MAAM,iBAAiB,EAAE,CAAA;IAEzB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA7ID,kCA6IC","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 { version } from '../version'\nimport { IFilterablePickle } from '../filter'\nimport { makeRuntime } from '../runtime'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\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 logger.debug(`Running cucumber-js ${version} \nWorking directory: ${cwd}\nRunning from: ${__dirname} \n`)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'originalCoordinates' in options.support\n ? options.support.originalCoordinates\n : Object.assign(\n {\n requireModules: [],\n requirePaths: [],\n loaders: [],\n importPaths: [],\n },\n options.support\n )\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 logger,\n cwd,\n newId,\n requirePaths,\n requireModules: supportCoordinates.requireModules,\n importPaths,\n loaders: supportCoordinates.loaders,\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 pluginManager,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let filteredPickles: ReadonlyArray<IFilterablePickle> = []\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 filteredPickles = await pluginManager.transform(\n 'pickles:filter',\n gherkinResult.filterablePickles\n )\n filteredPickles = await pluginManager.transform(\n 'pickles:order',\n filteredPickles\n )\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 = await makeRuntime({\n environment,\n logger,\n eventBroadcaster,\n sourcedPickles: filteredPickles,\n newId,\n supportCodeLibrary,\n options: options.runtime,\n })\n const success = await runtime.run()\n await pluginManager.cleanup()\n await cleanupFormatters()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
|
-
import * as messages from '@cucumber/messages';
|
|
4
3
|
import { IdGenerator } from '@cucumber/messages';
|
|
5
4
|
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
|
-
|
|
7
|
-
export
|
|
5
|
+
import { AssembledTestCase, SourcedPickle } from './types';
|
|
6
|
+
export declare function assembleTestCases({ eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, }: {
|
|
8
7
|
eventBroadcaster: EventEmitter;
|
|
9
8
|
newId: IdGenerator.NewId;
|
|
10
|
-
|
|
9
|
+
sourcedPickles: ReadonlyArray<SourcedPickle>;
|
|
11
10
|
supportCodeLibrary: SupportCodeLibrary;
|
|
12
|
-
}
|
|
13
|
-
export declare function assembleTestCases({ eventBroadcaster, newId, pickles, supportCodeLibrary, }: IAssembleTestCasesOptions): Promise<IAssembledTestCases>;
|
|
11
|
+
}): Promise<ReadonlyArray<AssembledTestCase>>;
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assembleTestCases = void 0;
|
|
4
4
|
const value_checker_1 = require("../value_checker");
|
|
5
|
-
async function assembleTestCases({ eventBroadcaster, newId,
|
|
6
|
-
|
|
7
|
-
for (const pickle of pickles) {
|
|
8
|
-
const { id: pickleId } = pickle;
|
|
5
|
+
async function assembleTestCases({ eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, }) {
|
|
6
|
+
return sourcedPickles.map(({ gherkinDocument, pickle }) => {
|
|
9
7
|
const testCaseId = newId();
|
|
10
8
|
const fromBeforeHooks = makeBeforeHookSteps({
|
|
11
9
|
supportCodeLibrary,
|
|
@@ -23,7 +21,7 @@ async function assembleTestCases({ eventBroadcaster, newId, pickles, supportCode
|
|
|
23
21
|
newId,
|
|
24
22
|
});
|
|
25
23
|
const testCase = {
|
|
26
|
-
pickleId,
|
|
24
|
+
pickleId: pickle.id,
|
|
27
25
|
id: testCaseId,
|
|
28
26
|
testSteps: [
|
|
29
27
|
...fromBeforeHooks,
|
|
@@ -32,9 +30,12 @@ async function assembleTestCases({ eventBroadcaster, newId, pickles, supportCode
|
|
|
32
30
|
],
|
|
33
31
|
};
|
|
34
32
|
eventBroadcaster.emit('envelope', { testCase });
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return {
|
|
34
|
+
gherkinDocument,
|
|
35
|
+
pickle,
|
|
36
|
+
testCase,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
38
39
|
}
|
|
39
40
|
exports.assembleTestCases = assembleTestCases;
|
|
40
41
|
function makeAfterHookSteps({ supportCodeLibrary, pickle, newId, }) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assemble_test_cases.js","sourceRoot":"","sources":["../../src/assemble/assemble_test_cases.ts"],"names":[],"mappings":";;;AAWA,oDAAgD;AAGzC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,KAAK,EACL,cAAc,EACd,kBAAkB,GAMnB;IACC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,EAAE;QACxD,MAAM,UAAU,GAAG,KAAK,EAAE,CAAA;QAC1B,MAAM,eAAe,GAAe,mBAAmB,CAAC;YACtD,kBAAkB;YAClB,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QACF,MAAM,mBAAmB,GAAe,SAAS,CAAC;YAChD,MAAM;YACN,kBAAkB;YAClB,KAAK;SACN,CAAC,CAAA;QACF,MAAM,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AAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport {\n Envelope,\n IdGenerator,\n Pickle,\n TestCase,\n TestStep,\n Group as MessagesGroup,\n} from '@cucumber/messages'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { doesHaveValue } from '../value_checker'\nimport { AssembledTestCase, SourcedPickle } from './types'\n\nexport async function assembleTestCases({\n eventBroadcaster,\n newId,\n sourcedPickles,\n supportCodeLibrary,\n}: {\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n sourcedPickles: ReadonlyArray<SourcedPickle>\n supportCodeLibrary: SupportCodeLibrary\n}): Promise<ReadonlyArray<AssembledTestCase>> {\n return sourcedPickles.map(({ gherkinDocument, pickle }) => {\n const testCaseId = newId()\n const fromBeforeHooks: TestStep[] = makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const fromStepDefinitions: TestStep[] = makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n })\n const fromAfterHooks: TestStep[] = makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n })\n const testCase: TestCase = {\n pickleId: pickle.id,\n id: testCaseId,\n testSteps: [\n ...fromBeforeHooks,\n ...fromStepDefinitions,\n ...fromAfterHooks,\n ],\n }\n eventBroadcaster.emit('envelope', { testCase } satisfies Envelope)\n return {\n gherkinDocument,\n pickle,\n testCase,\n }\n })\n}\n\nfunction makeAfterHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: SupportCodeLibrary\n pickle: Pickle\n newId: IdGenerator.NewId\n}): TestStep[] {\n return supportCodeLibrary.afterTestCaseHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeBeforeHookSteps({\n supportCodeLibrary,\n pickle,\n newId,\n}: {\n supportCodeLibrary: SupportCodeLibrary\n pickle: Pickle\n newId: IdGenerator.NewId\n}): TestStep[] {\n return supportCodeLibrary.beforeTestCaseHookDefinitions\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(pickle))\n .map((hookDefinition) => ({\n id: newId(),\n hookId: hookDefinition.id,\n }))\n}\n\nfunction makeSteps({\n pickle,\n supportCodeLibrary,\n newId,\n}: {\n pickle: Pickle\n supportCodeLibrary: SupportCodeLibrary\n newId: () => string\n}): TestStep[] {\n return pickle.steps.map((pickleStep) => {\n const stepDefinitions = supportCodeLibrary.stepDefinitions.filter(\n (stepDefinition) => stepDefinition.matchesStepName(pickleStep.text)\n )\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n stepDefinitionIds: stepDefinitions.map(\n (stepDefinition) => stepDefinition.id\n ),\n stepMatchArgumentsLists: stepDefinitions.map((stepDefinition) => {\n const result = stepDefinition.expression.match(pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n })\n}\n\nfunction mapArgumentGroup(group: Group): MessagesGroup {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => mapArgumentGroup(child))\n : undefined,\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./assemble_test_cases"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assemble/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,0CAAuB","sourcesContent":["export * from './assemble_test_cases'\nexport * from './types'\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GherkinDocument, Pickle, TestCase } from '@cucumber/messages';
|
|
2
|
+
export interface SourcedPickle {
|
|
3
|
+
gherkinDocument: GherkinDocument;
|
|
4
|
+
pickle: Pickle;
|
|
5
|
+
}
|
|
6
|
+
export interface AssembledTestCase {
|
|
7
|
+
gherkinDocument: GherkinDocument;
|
|
8
|
+
pickle: Pickle;
|
|
9
|
+
testCase: TestCase;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/assemble/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GherkinDocument, Pickle, TestCase } from '@cucumber/messages'\n\nexport interface SourcedPickle {\n gherkinDocument: GherkinDocument\n pickle: Pickle\n}\n\nexport interface AssembledTestCase {\n gherkinDocument: GherkinDocument\n pickle: Pickle\n testCase: TestCase\n}\n"]}
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
3
|
import { EventEmitter } from 'node:events';
|
|
5
|
-
import { Readable } from 'node:stream';
|
|
6
4
|
import { IdGenerator } from '@cucumber/messages';
|
|
7
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
8
|
-
import PickleFilter from '../pickle_filter';
|
|
9
5
|
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
10
6
|
import { ILogger } from '../logger';
|
|
11
7
|
import { IPickleOrder } from '../filter';
|
|
12
|
-
interface IParseGherkinMessageStreamRequest {
|
|
13
|
-
cwd?: string;
|
|
14
|
-
eventBroadcaster: EventEmitter;
|
|
15
|
-
eventDataCollector: EventDataCollector;
|
|
16
|
-
gherkinMessageStream: Readable;
|
|
17
|
-
order: string;
|
|
18
|
-
pickleFilter: PickleFilter;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
22
|
-
*
|
|
23
|
-
* @param eventBroadcaster
|
|
24
|
-
* @param eventDataCollector
|
|
25
|
-
* @param gherkinMessageStream
|
|
26
|
-
* @param order
|
|
27
|
-
* @param pickleFilter
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }: IParseGherkinMessageStreamRequest): Promise<string[]>;
|
|
30
8
|
export declare function orderPickles<T = string>(pickleIds: T[], order: IPickleOrder, logger: ILogger): void;
|
|
31
9
|
export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv): Promise<void>;
|
|
32
10
|
export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
|
|
@@ -34,4 +12,3 @@ export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeL
|
|
|
34
12
|
supportCodeLibrary: SupportCodeLibrary;
|
|
35
13
|
newId: IdGenerator.NewId;
|
|
36
14
|
}): void;
|
|
37
|
-
export {};
|
package/lib/cli/helpers.js
CHANGED
|
@@ -26,44 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles =
|
|
29
|
+
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles = void 0;
|
|
30
30
|
const node_os_1 = __importDefault(require("node:os"));
|
|
31
31
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
32
32
|
const messages = __importStar(require("@cucumber/messages"));
|
|
33
33
|
const ci_environment_1 = __importDefault(require("@cucumber/ci-environment"));
|
|
34
|
-
const value_checker_1 = require("../value_checker");
|
|
35
34
|
const version_1 = require("../version");
|
|
36
|
-
/**
|
|
37
|
-
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
38
|
-
*
|
|
39
|
-
* @param eventBroadcaster
|
|
40
|
-
* @param eventDataCollector
|
|
41
|
-
* @param gherkinMessageStream
|
|
42
|
-
* @param order
|
|
43
|
-
* @param pickleFilter
|
|
44
|
-
*/
|
|
45
|
-
async function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }) {
|
|
46
|
-
return await new Promise((resolve, reject) => {
|
|
47
|
-
const result = [];
|
|
48
|
-
gherkinMessageStream.on('data', (envelope) => {
|
|
49
|
-
eventBroadcaster.emit('envelope', envelope);
|
|
50
|
-
if ((0, value_checker_1.doesHaveValue)(envelope.pickle)) {
|
|
51
|
-
const pickle = envelope.pickle;
|
|
52
|
-
const pickleId = pickle.id;
|
|
53
|
-
const gherkinDocument = eventDataCollector.getGherkinDocument(pickle.uri);
|
|
54
|
-
if (pickleFilter.matches({ gherkinDocument, pickle })) {
|
|
55
|
-
result.push(pickleId);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
gherkinMessageStream.on('end', () => {
|
|
60
|
-
orderPickles(result, order, console);
|
|
61
|
-
resolve(result);
|
|
62
|
-
});
|
|
63
|
-
gherkinMessageStream.on('error', reject);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
exports.parseGherkinMessageStream = parseGherkinMessageStream;
|
|
67
35
|
// Orders the pickleIds in place - morphs input
|
|
68
36
|
function orderPickles(pickleIds, order, logger) {
|
|
69
37
|
const [type, seed] = splitOrder(order);
|
package/lib/cli/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sDAAwB;AACxB,gFAA0C;AAC1C,6DAA8C;AAE9C,8EAA0D;AAC1D,oDAAgD;AAMhD,wCAAoC;AAcpC;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAAC,EAC9C,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,YAAY,GACsB;IAClC,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAA2B,EAAE,EAAE;YAC9D,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3C,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAA;gBAC1B,MAAM,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAC3D,MAAM,CAAC,GAAG,CACX,CAAA;gBACD,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE;oBACrD,MAAM,CAAC,IAAI,CAAC,QAAQ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\nimport os from 'node:os'\nimport shuffle from 'knuth-shuffle-seeded'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { doesHaveValue } from '../value_checker'\nimport { EventDataCollector } from '../formatter/helpers'\nimport PickleFilter from '../pickle_filter'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { version } from '../version'\nimport { ILogger } from '../logger'\nimport { ILineAndUri } from '../types'\nimport { IPickleOrder } from '../filter'\n\ninterface IParseGherkinMessageStreamRequest {\n cwd?: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\n/**\n * Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids\n *\n * @param eventBroadcaster\n * @param eventDataCollector\n * @param gherkinMessageStream\n * @param order\n * @param pickleFilter\n */\nexport async function parseGherkinMessageStream({\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickles(result, order as IPickleOrder, console)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: IPickleOrder,\n logger: ILogger\n): void {\n const [type, seed] = splitOrder(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n const newSeed = Math.floor(Math.random() * 1000 * 1000).toString()\n logger.warn(`Random order using seed: ${newSeed}`)\n shuffle(pickleIds, newSeed)\n } else {\n shuffle(pickleIds, seed)\n }\n break\n default:\n throw new Error(\n 'Unrecognized order type. Should be `defined` or `random`'\n )\n }\n}\n\nfunction splitOrder(order: string) {\n if (!order.includes(':')) {\n return [order, '']\n }\n return order.split(':')\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter,\n env: NodeJS.ProcessEnv\n): Promise<void> {\n const meta: messages.Meta = {\n protocolVersion: messages.version,\n implementation: {\n version,\n name: 'cucumber-js',\n },\n cpu: {\n name: os.arch(),\n },\n os: {\n name: os.platform(),\n version: os.release(),\n },\n runtime: {\n name: 'node.js',\n version: process.versions.node,\n },\n ci: detectCiEnvironment(env),\n }\n eventBroadcaster.emit('envelope', {\n meta,\n })\n}\n\nconst makeSourceReference = (source: ILineAndUri) => ({\n uri: source.uri,\n location: {\n line: source.line,\n },\n})\n\nfunction emitParameterTypes(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (parameterType.builtin) {\n continue\n }\n const source =\n supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType)\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n sourceReference: makeSourceReference(source),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: makeSourceReference(stepDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n name: testCaseHookDefinition.name,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: makeSourceReference(testCaseHookDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: makeSourceReference(testRunHookDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: SupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAAwB;AACxB,gFAA0C;AAC1C,6DAA8C;AAE9C,8EAA0D;AAI1D,wCAAoC;AAKpC,+CAA+C;AAC/C,SAAgB,YAAY,CAC1B,SAAc,EACd,KAAmB,EACnB,MAAe;IAEf,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IACtC,QAAQ,IAAI,EAAE;QACZ,KAAK,SAAS;YACZ,MAAK;QACP,KAAK,QAAQ;YACX,IAAI,IAAI,KAAK,EAAE,EAAE;gBACf,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAClE,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAA;gBAClD,IAAA,8BAAO,EAAC,SAAS,EAAE,OAAO,CAAC,CAAA;aAC5B;iBAAM;gBACL,IAAA,8BAAO,EAAC,SAAS,EAAE,IAAI,CAAC,CAAA;aACzB;YACD,MAAK;QACP;YACE,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAA;KACJ;AACH,CAAC;AAvBD,oCAuBC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACxB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;KACnB;IACD,OAAO,KAAK,CAAC,KAAK,CAAC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mitter } from 'node:events'\nimport os from 'node:os'\nimport shuffle from 'knuth-shuffle-seeded'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { version } from '../version'\nimport { ILogger } from '../logger'\nimport { ILineAndUri } from '../types'\nimport { IPickleOrder } from '../filter'\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: IPickleOrder,\n logger: ILogger\n): void {\n const [type, seed] = splitOrder(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n const newSeed = Math.floor(Math.random() * 1000 * 1000).toString()\n logger.warn(`Random order using seed: ${newSeed}`)\n shuffle(pickleIds, newSeed)\n } else {\n shuffle(pickleIds, seed)\n }\n break\n default:\n throw new Error(\n 'Unrecognized order type. Should be `defined` or `random`'\n )\n }\n}\n\nfunction splitOrder(order: string) {\n if (!order.includes(':')) {\n return [order, '']\n }\n return order.split(':')\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter,\n env: NodeJS.ProcessEnv\n): Promise<void> {\n const meta: messages.Meta = {\n protocolVersion: messages.version,\n implementation: {\n version,\n name: 'cucumber-js',\n },\n cpu: {\n name: os.arch(),\n },\n os: {\n name: os.platform(),\n version: os.release(),\n },\n runtime: {\n name: 'node.js',\n version: process.versions.node,\n },\n ci: detectCiEnvironment(env),\n }\n eventBroadcaster.emit('envelope', {\n meta,\n })\n}\n\nconst makeSourceReference = (source: ILineAndUri) => ({\n uri: source.uri,\n location: {\n line: source.line,\n },\n})\n\nfunction emitParameterTypes(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (parameterType.builtin) {\n continue\n }\n const source =\n supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType)\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n sourceReference: makeSourceReference(source),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: makeSourceReference(stepDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n name: testCaseHookDefinition.name,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: makeSourceReference(testCaseHookDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: makeSourceReference(testRunHookDefinition),\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: SupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,11 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import * as messages from '@cucumber/messages';
|
|
10
10
|
import { default as _Cli } from './cli';
|
|
11
|
-
import * as cliHelpers from './cli/helpers';
|
|
12
11
|
import * as formatterHelpers from './formatter/helpers';
|
|
13
|
-
import { default as _PickleFilter } from './pickle_filter';
|
|
14
12
|
import * as parallelCanAssignHelpers from './support_code_library_builder/parallel_can_assign_helpers';
|
|
15
|
-
import { default as _Runtime } from './runtime';
|
|
16
13
|
export declare const version: string;
|
|
17
14
|
export { default as supportCodeLibraryBuilder } from './support_code_library_builder';
|
|
18
15
|
export { default as DataTable } from './models/data_table';
|
|
@@ -53,16 +50,3 @@ export { wrapPromiseWithTimeout } from './time';
|
|
|
53
50
|
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
54
51
|
*/
|
|
55
52
|
export declare const Cli: typeof _Cli;
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
58
|
-
*/
|
|
59
|
-
export declare const parseGherkinMessageStream: typeof cliHelpers.parseGherkinMessageStream;
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
62
|
-
*/
|
|
63
|
-
export declare const PickleFilter: typeof _PickleFilter;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
66
|
-
*/
|
|
67
|
-
export declare const Runtime: typeof _Runtime;
|
|
68
|
-
export { INewRuntimeOptions, IRuntimeOptions } from './runtime';
|
package/lib/index.js
CHANGED
|
@@ -34,17 +34,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
37
|
+
exports.Cli = exports.wrapPromiseWithTimeout = exports.Status = exports.parallelCanAssignHelpers = exports.context = exports.world = exports.World = exports.When = exports.Then = exports.setParallelCanAssign = exports.setWorldConstructor = exports.setDefinitionFunctionWrapper = exports.setDefaultTimeout = exports.Given = exports.defineParameterType = exports.defineStep = exports.BeforeStep = exports.BeforeAll = exports.Before = exports.AfterStep = exports.AfterAll = exports.After = exports.formatterHelpers = exports.UsageJsonFormatter = exports.UsageFormatter = exports.SummaryFormatter = exports.SnippetsFormatter = exports.RerunFormatter = exports.ProgressFormatter = exports.JsonFormatter = exports.FormatterBuilder = exports.Formatter = exports.TestCaseHookDefinition = exports.DataTable = exports.supportCodeLibraryBuilder = exports.version = void 0;
|
|
38
38
|
const node_util_1 = require("node:util");
|
|
39
39
|
const messages = __importStar(require("@cucumber/messages"));
|
|
40
40
|
const cli_1 = __importDefault(require("./cli"));
|
|
41
|
-
const cliHelpers = __importStar(require("./cli/helpers"));
|
|
42
41
|
const formatterHelpers = __importStar(require("./formatter/helpers"));
|
|
43
42
|
exports.formatterHelpers = formatterHelpers;
|
|
44
|
-
const pickle_filter_1 = __importDefault(require("./pickle_filter"));
|
|
45
43
|
const parallelCanAssignHelpers = __importStar(require("./support_code_library_builder/parallel_can_assign_helpers"));
|
|
46
44
|
exports.parallelCanAssignHelpers = parallelCanAssignHelpers;
|
|
47
|
-
const runtime_1 = __importDefault(require("./runtime"));
|
|
48
45
|
const support_code_library_builder_1 = __importDefault(require("./support_code_library_builder"));
|
|
49
46
|
const version_1 = require("./version");
|
|
50
47
|
// type version as string to avoid tripping api-extractor every release
|
|
@@ -106,16 +103,4 @@ Object.defineProperty(exports, "wrapPromiseWithTimeout", { enumerable: true, get
|
|
|
106
103
|
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
107
104
|
*/
|
|
108
105
|
exports.Cli = (0, node_util_1.deprecate)(cli_1.default, '`Cli` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
109
|
-
/**
|
|
110
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
111
|
-
*/
|
|
112
|
-
exports.parseGherkinMessageStream = (0, node_util_1.deprecate)(cliHelpers.parseGherkinMessageStream, '`parseGherkinMessageStream` is deprecated, use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
113
|
-
/**
|
|
114
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
115
|
-
*/
|
|
116
|
-
exports.PickleFilter = (0, node_util_1.deprecate)(pickle_filter_1.default, '`PickleFilter` is deprecated, use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
119
|
-
*/
|
|
120
|
-
exports.Runtime = (0, node_util_1.deprecate)(runtime_1.default, '`Runtime` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
121
106
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAqC;AACrC,6DAA8C;AAC9C,gDAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAqC;AACrC,6DAA8C;AAC9C,gDAAuC;AACvC,sEAAuD;AAuB9C,4CAAgB;AAtBzB,qHAAsG;AAgD7F,4DAAwB;AA/CjC,kGAAsE;AACtE,uCAA+C;AAE/C,uEAAuE;AAC1D,QAAA,OAAO,GAAG,iBAAkB,CAAA;AAEzC,YAAY;AACZ,+EAAqF;AAA5E,0JAAA,OAAO,OAA6B;AAC7C,kDAA0D;AAAjD,wHAAA,OAAO,OAAa;AAC7B,gFAAsF;AAA7E,oJAAA,OAAO,OAA0B;AAE1C,aAAa;AACb,yCAAqE;AAA5D,uHAAA,OAAO,OAAa;AAC7B,+CAAiE;AAAxD,4HAAA,OAAO,OAAoB;AACpC,6DAAqE;AAA5D,gIAAA,OAAO,OAAiB;AACjC,qEAA6E;AAApE,wIAAA,OAAO,OAAqB;AACrC,+DAAuE;AAA9D,kIAAA,OAAO,OAAkB;AAClC,qEAA6E;AAApE,wIAAA,OAAO,OAAqB;AACrC,mEAA2E;AAAlE,sIAAA,OAAO,OAAoB;AACpC,+DAAuE;AAA9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*\n * @packageDocumentation\n * @module (root)\n * @remarks\n * These docs cover the functions and helpers for user code registration and test setup. The entry point is `@cucumber/cucumber`.\n */\n\nimport { deprecate } from 'node:util'\nimport * as messages from '@cucumber/messages'\nimport { default as _Cli } from './cli'\nimport * as formatterHelpers from './formatter/helpers'\nimport * as parallelCanAssignHelpers from './support_code_library_builder/parallel_can_assign_helpers'\nimport supportCodeLibraryBuilder from './support_code_library_builder'\nimport { version as _version } from './version'\n\n// type version as string to avoid tripping api-extractor every release\nexport const version = _version as string\n\n// Top level\nexport { default as supportCodeLibraryBuilder } from './support_code_library_builder'\nexport { default as DataTable } from './models/data_table'\nexport { default as TestCaseHookDefinition } from './models/test_case_hook_definition'\n\n// Formatters\nexport { default as Formatter, IFormatterOptions } from './formatter'\nexport { default as FormatterBuilder } from './formatter/builder'\nexport { default as JsonFormatter } from './formatter/json_formatter'\nexport { default as ProgressFormatter } from './formatter/progress_formatter'\nexport { default as RerunFormatter } from './formatter/rerun_formatter'\nexport { default as SnippetsFormatter } from './formatter/snippets_formatter'\nexport { default as SummaryFormatter } from './formatter/summary_formatter'\nexport { default as UsageFormatter } from './formatter/usage_formatter'\nexport { default as UsageJsonFormatter } from './formatter/usage_json_formatter'\nexport { formatterHelpers }\n\n// Support Code Functions\nconst { methods } = supportCodeLibraryBuilder\nexport const After = methods.After\nexport const AfterAll = methods.AfterAll\nexport const AfterStep = methods.AfterStep\nexport const Before = methods.Before\nexport const BeforeAll = methods.BeforeAll\nexport const BeforeStep = methods.BeforeStep\nexport const defineStep = methods.defineStep\nexport const defineParameterType = methods.defineParameterType\nexport const Given = methods.Given\nexport const setDefaultTimeout = methods.setDefaultTimeout\nexport const setDefinitionFunctionWrapper = methods.setDefinitionFunctionWrapper\nexport const setWorldConstructor = methods.setWorldConstructor\nexport const setParallelCanAssign = methods.setParallelCanAssign\nexport const Then = methods.Then\nexport const When = methods.When\nexport {\n default as World,\n IWorld,\n IWorldOptions,\n} from './support_code_library_builder/world'\nexport { IContext } from './support_code_library_builder/context'\nexport { worldProxy as world, contextProxy as context } from './runtime/scope'\nexport { parallelCanAssignHelpers }\n\nexport {\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from './support_code_library_builder/types'\nexport const Status = messages.TestStepResultStatus\n\n// Time helpers\nexport { wrapPromiseWithTimeout } from './time'\n\n// Deprecated\n/**\n * @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md\n */\nexport const Cli = deprecate(\n _Cli,\n '`Cli` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md'\n)\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import { SourcedPickle } from '../assemble';
|
|
5
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
|
+
import { RuntimeAdapter } from './types';
|
|
7
|
+
import { Runtime } from './index';
|
|
8
|
+
export declare class Coordinator implements Runtime {
|
|
9
|
+
private eventBroadcaster;
|
|
10
|
+
private newId;
|
|
11
|
+
private sourcedPickles;
|
|
12
|
+
private supportCodeLibrary;
|
|
13
|
+
private adapter;
|
|
14
|
+
constructor(eventBroadcaster: EventEmitter, newId: IdGenerator.NewId, sourcedPickles: ReadonlyArray<SourcedPickle>, supportCodeLibrary: SupportCodeLibrary, adapter: RuntimeAdapter);
|
|
15
|
+
run(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Coordinator = void 0;
|
|
4
|
+
const assemble_1 = require("../assemble");
|
|
5
|
+
const stopwatch_1 = require("./stopwatch");
|
|
6
|
+
class Coordinator {
|
|
7
|
+
eventBroadcaster;
|
|
8
|
+
newId;
|
|
9
|
+
sourcedPickles;
|
|
10
|
+
supportCodeLibrary;
|
|
11
|
+
adapter;
|
|
12
|
+
constructor(eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter) {
|
|
13
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
14
|
+
this.newId = newId;
|
|
15
|
+
this.sourcedPickles = sourcedPickles;
|
|
16
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
17
|
+
this.adapter = adapter;
|
|
18
|
+
}
|
|
19
|
+
async run() {
|
|
20
|
+
this.eventBroadcaster.emit('envelope', {
|
|
21
|
+
testRunStarted: {
|
|
22
|
+
timestamp: (0, stopwatch_1.timestamp)(),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const assembledTestCases = await (0, assemble_1.assembleTestCases)({
|
|
26
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
27
|
+
newId: this.newId,
|
|
28
|
+
sourcedPickles: this.sourcedPickles,
|
|
29
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
30
|
+
});
|
|
31
|
+
const success = await this.adapter.run(assembledTestCases);
|
|
32
|
+
this.eventBroadcaster.emit('envelope', {
|
|
33
|
+
testRunFinished: {
|
|
34
|
+
timestamp: (0, stopwatch_1.timestamp)(),
|
|
35
|
+
success,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return success;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Coordinator = Coordinator;
|
|
42
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../src/runtime/coordinator.ts"],"names":[],"mappings":";;;AAEA,0CAA8D;AAG9D,2CAAuC;AAGvC,MAAa,WAAW;IAEZ;IACA;IACA;IACA;IACA;IALV,YACU,gBAA8B,EAC9B,KAAwB,EACxB,cAA4C,EAC5C,kBAAsC,EACtC,OAAuB;QAJvB,qBAAgB,GAAhB,gBAAgB,CAAc;QAC9B,UAAK,GAAL,KAAK,CAAmB;QACxB,mBAAc,GAAd,cAAc,CAA8B;QAC5C,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,YAAO,GAAP,OAAO,CAAgB;IAC9B,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE;YACrC,cAAc,EAAE;gBACd,SAAS,EAAE,IAAA,qBAAS,GAAE;aACvB;SACiB,CAAC,CAAA;QAErB,MAAM,kBAAkB,GAAG,MAAM,IAAA,4BAAiB,EAAC;YACjD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QAE1D,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE;YACrC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAA,qBAAS,GAAE;gBACtB,OAAO;aACR;SACiB,CAAC,CAAA;QAErB,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAlCD,kCAkCC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator } from '@cucumber/messages'\nimport { assembleTestCases, SourcedPickle } from '../assemble'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { RuntimeAdapter } from './types'\nimport { timestamp } from './stopwatch'\nimport { Runtime } from './index'\n\nexport class Coordinator implements Runtime {\n constructor(\n private eventBroadcaster: EventEmitter,\n private newId: IdGenerator.NewId,\n private sourcedPickles: ReadonlyArray<SourcedPickle>,\n private supportCodeLibrary: SupportCodeLibrary,\n private adapter: RuntimeAdapter\n ) {}\n\n async run(): Promise<boolean> {\n this.eventBroadcaster.emit('envelope', {\n testRunStarted: {\n timestamp: timestamp(),\n },\n } satisfies Envelope)\n\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n sourcedPickles: this.sourcedPickles,\n supportCodeLibrary: this.supportCodeLibrary,\n })\n\n const success = await this.adapter.run(assembledTestCases)\n\n this.eventBroadcaster.emit('envelope', {\n testRunFinished: {\n timestamp: timestamp(),\n success,\n },\n } satisfies Envelope)\n\n return success\n }\n}\n"]}
|
package/lib/runtime/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
2
|
import StepDefinition from '../models/step_definition';
|
|
3
|
-
import {
|
|
3
|
+
import { RuntimeOptions } from '.';
|
|
4
4
|
export declare function getAmbiguousStepException(stepDefinitions: StepDefinition[]): string;
|
|
5
|
-
export declare function retriesForPickle(pickle: messages.Pickle, options:
|
|
6
|
-
export declare function shouldCauseFailure(status: messages.TestStepResultStatus, options:
|
|
5
|
+
export declare function retriesForPickle(pickle: messages.Pickle, options: RuntimeOptions): number;
|
|
6
|
+
export declare function shouldCauseFailure(status: messages.TestStepResultStatus, options: RuntimeOptions): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8B;AAC9B,kEAAwC;AACxC,6DAA8C;AAC9C,4EAAsE;AACtE,oDAAkD;AAIlD,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,KAAK;Y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K,CAAA;KACb;IACD,MAAM,eAAe,GAAoC;QACvD,QAAQ,CAAC,oBAAoB,CAAC,SAAS;QACvC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;QACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;KACxC,CAAA;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC5D;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","sourcesContent":["import Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport { formatLocation } from '../formatter/helpers/location_helpers'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport { RuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: RuntimeOptions\n): number {\n if (!options.retry) {\n return 0\n }\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (!retryTagFilter) {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: RuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
|
package/lib/runtime/index.d.ts
CHANGED
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as messages from '@cucumber/messages';
|
|
4
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
5
|
-
import { JsonObject } from 'type-fest';
|
|
6
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
7
|
-
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
-
export interface IRuntime {
|
|
9
|
-
start: () => Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export interface INewRuntimeOptions {
|
|
12
|
-
eventBroadcaster: EventEmitter;
|
|
13
|
-
eventDataCollector: EventDataCollector;
|
|
14
|
-
newId: IdGenerator.NewId;
|
|
15
|
-
options: IRuntimeOptions;
|
|
16
|
-
pickleIds: string[];
|
|
17
|
-
supportCodeLibrary: SupportCodeLibrary;
|
|
18
|
-
}
|
|
19
|
-
export interface IRuntimeOptions {
|
|
20
|
-
dryRun: boolean;
|
|
21
|
-
failFast: boolean;
|
|
22
|
-
filterStacktraces: boolean;
|
|
23
|
-
retry: number;
|
|
24
|
-
retryTagFilter: string;
|
|
25
|
-
strict: boolean;
|
|
26
|
-
worldParameters: JsonObject;
|
|
27
|
-
}
|
|
28
|
-
export default class Runtime implements IRuntime {
|
|
29
|
-
private readonly eventBroadcaster;
|
|
30
|
-
private readonly eventDataCollector;
|
|
31
|
-
private readonly stopwatch;
|
|
32
|
-
private readonly newId;
|
|
33
|
-
private readonly options;
|
|
34
|
-
private readonly pickleIds;
|
|
35
|
-
private readonly supportCodeLibrary;
|
|
36
|
-
private success;
|
|
37
|
-
private readonly runTestRunHooks;
|
|
38
|
-
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
|
|
39
|
-
runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
|
|
40
|
-
start(): Promise<boolean>;
|
|
41
|
-
}
|
|
1
|
+
export * from './make_runtime';
|
|
2
|
+
export { Runtime, RuntimeOptions } from './types';
|