@cucumber/cucumber 12.2.0 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/api/run_cucumber.js +1 -0
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/cli/helpers.js +11 -1
- package/lib/cli/helpers.js.map +1 -1
- package/lib/configuration/argv_parser.js +1 -1
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/filter/types.d.ts +2 -1
- package/lib/filter/types.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +1 -0
- package/lib/formatter/step_definition_snippet_builder/index.js +14 -0
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/models/test_run_hook_definition.d.ts +6 -1
- package/lib/models/test_run_hook_definition.js +5 -0
- package/lib/models/test_run_hook_definition.js.map +1 -1
- package/lib/runtime/coordinator.d.ts +2 -1
- package/lib/runtime/coordinator.js +6 -5
- package/lib/runtime/coordinator.js.map +1 -1
- package/lib/runtime/make_runtime.d.ts +4 -3
- package/lib/runtime/make_runtime.js +20 -5
- package/lib/runtime/make_runtime.js.map +1 -1
- package/lib/runtime/make_suggestion.d.ts +7 -0
- package/lib/runtime/make_suggestion.js +31 -0
- package/lib/runtime/make_suggestion.js.map +1 -0
- package/lib/runtime/parallel/adapter.d.ts +4 -1
- package/lib/runtime/parallel/adapter.js +9 -1
- package/lib/runtime/parallel/adapter.js.map +1 -1
- package/lib/runtime/parallel/types.d.ts +3 -0
- package/lib/runtime/parallel/types.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +1 -1
- package/lib/runtime/parallel/worker.js +9 -2
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/serial/adapter.d.ts +2 -1
- package/lib/runtime/serial/adapter.js +2 -2
- package/lib/runtime/serial/adapter.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +4 -1
- package/lib/runtime/test_case_runner.js +12 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/runtime/worker.d.ts +14 -6
- package/lib/runtime/worker.js +106 -14
- package/lib/runtime/worker.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +1 -1
- package/lib/support_code_library_builder/index.js +6 -6
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +3 -0
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/tsconfig.node.tsbuildinfo +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +26 -26
- package/lib/runtime/run_test_run_hooks.d.ts +0 -4
- package/lib/runtime/run_test_run_hooks.js +0 -29
- package/lib/runtime/run_test_run_hooks.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<p align="center">
|
|
11
11
|
<a href="https://www.npmjs.com/package/@cucumber/cucumber" style="text-decoration: none"><img src="https://img.shields.io/npm/v/@cucumber/cucumber?style=flat&color=dark-green" alt="Latest version on npm"></a>
|
|
12
|
-
<a href="https://github.com/cucumber/cucumber-js/actions" style="text-decoration: none"><img src="https://github.com/cucumber/cucumber-js/actions/workflows/build.
|
|
12
|
+
<a href="https://github.com/cucumber/cucumber-js/actions" style="text-decoration: none"><img src="https://github.com/cucumber/cucumber-js/actions/workflows/build.yml/badge.svg" alt="Build status"></a>
|
|
13
13
|
<a href="https://coveralls.io/github/cucumber/cucumber-js?branch=master" style="text-decoration: none"><img src="https://coveralls.io/repos/github/cucumber/cucumber-js/badge.svg?branch=main" alt="Coverage"></a>
|
|
14
14
|
<a href="https://opencollective.com/cucumber"><img src="https://opencollective.com/cucumber/backers/badge.svg" alt="Backers"></a>
|
|
15
15
|
<a href="https://opencollective.com/cucumber"><img src="https://opencollective.com/cucumber/sponsors/badge.svg" alt="Sponsors"></a>
|
package/lib/api/run_cucumber.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;AAwBA,
|
|
1
|
+
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;AAwBA,kCA6IC;AArKD,6CAA0C;AAC1C,iDAAsE;AACtE,kDAAyD;AACzD,4CAAyE;AACzE,oCAAuC;AAEvC,wCAAoC;AAEpC,wCAAwC;AACxC,gDAAiE;AAEjE,6CAAmD;AACnD,uCAAiD;AACjD,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,6BAAe,EAAC,WAAW,CAAC,CAAA;IACtD,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;QACE,GAAG,OAAO;QACV,OAAO,EAAE,kBAAkB;KAC5B,EACD,iBAAiB,CAClB,CAAA;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAY,EACtC,MAAM,EACN,GAAG,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Ac,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;KACxC,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","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 { IRunEnvironment, makeEnvironment } from '../environment'\nimport { IRunOptions, IRunResult } from './types'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\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 = makeEnvironment(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 {\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 snippetOptions: options.formats.options,\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"]}
|
package/lib/cli/helpers.js
CHANGED
|
@@ -51,6 +51,9 @@ function orderPickles(pickleIds, order, logger) {
|
|
|
51
51
|
switch (type) {
|
|
52
52
|
case 'defined':
|
|
53
53
|
break;
|
|
54
|
+
case 'reverse':
|
|
55
|
+
pickleIds.reverse();
|
|
56
|
+
break;
|
|
54
57
|
case 'random':
|
|
55
58
|
if (seed === '') {
|
|
56
59
|
const newSeed = Math.floor(Math.random() * 1000 * 1000).toString();
|
|
@@ -135,7 +138,7 @@ function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
|
135
138
|
stepDefinition: {
|
|
136
139
|
id: stepDefinition.id,
|
|
137
140
|
pattern: {
|
|
138
|
-
source: stepDefinition.pattern
|
|
141
|
+
source: extractPatternSource(stepDefinition.pattern),
|
|
139
142
|
type: typeof stepDefinition.pattern === 'string'
|
|
140
143
|
? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION
|
|
141
144
|
: messages.StepDefinitionPatternType.REGULAR_EXPRESSION,
|
|
@@ -146,6 +149,12 @@ function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
|
|
|
146
149
|
eventBroadcaster.emit('envelope', envelope);
|
|
147
150
|
});
|
|
148
151
|
}
|
|
152
|
+
function extractPatternSource(pattern) {
|
|
153
|
+
if (pattern instanceof RegExp) {
|
|
154
|
+
return pattern.flags ? pattern.toString() : pattern.source;
|
|
155
|
+
}
|
|
156
|
+
return pattern;
|
|
157
|
+
}
|
|
149
158
|
function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
|
|
150
159
|
;
|
|
151
160
|
[
|
|
@@ -188,6 +197,7 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
|
|
|
188
197
|
hook: {
|
|
189
198
|
id: hook.id,
|
|
190
199
|
type,
|
|
200
|
+
name: hook.name,
|
|
191
201
|
sourceReference: makeSourceReference(hook),
|
|
192
202
|
},
|
|
193
203
|
});
|
package/lib/cli/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,oCAuBC;AASD,0CA0BC;AA2HD,0DAcC;AA/MD,sDAAwB;AACxB,gFAA0C;AAC1C,6DAA8C;AAC9C,iDAAoE;AACpE,8EAA0D;AAE1D,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,CAAC;QACb,KAAK,SAAS;YACZ,MAAK;QACP,KAAK,QAAQ;YACX,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;gBAChB,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;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAA,8BAAO,EAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YAC1B,CAAC;YACD,MAAK;QACP;YACE,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAA;IACL,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,K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AACJ,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport os from 'node:os'\nimport shuffle from 'knuth-shuffle-seeded'\nimport * as messages from '@cucumber/messages'\nimport { Envelope, HookType, IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { version } from '../version'\nimport { ILogger } from '../environment'\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 [\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n HookType.BEFORE_TEST_CASE,\n ] as const,\n [\n supportCodeLibrary.afterTestCaseHookDefinitions,\n HookType.AFTER_TEST_CASE,\n ] as const,\n ].forEach(([hooks, type]) => {\n hooks.forEach((hook) => {\n eventBroadcaster.emit('envelope', {\n hook: {\n id: hook.id,\n type,\n name: hook.name,\n tagExpression: hook.tagExpression,\n sourceReference: makeSourceReference(hook),\n },\n } satisfies Envelope)\n })\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[\n [\n supportCodeLibrary.beforeTestRunHookDefinitions,\n HookType.BEFORE_TEST_RUN,\n ] as const,\n [\n supportCodeLibrary.afterTestRunHookDefinitions,\n HookType.AFTER_TEST_RUN,\n ] as const,\n ].forEach(([hooks, type]) => {\n hooks.forEach((hook) => {\n eventBroadcaster.emit('envelope', {\n hook: {\n id: hook.id,\n type,\n sourceReference: makeSourceReference(hook),\n },\n } satisfies Envelope)\n })\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,oCA0BC;AASD,0CA0BC;AAmID,0DAcC;AA1ND,sDAAwB;AACxB,gFAA0C;AAC1C,6DA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,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport os from 'node:os'\nimport shuffle from 'knuth-shuffle-seeded'\nimport * as messages from '@cucumber/messages'\nimport { Envelope, HookType, IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { version } from '../version'\nimport { ILogger } from '../environment'\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 'reverse':\n pickleIds.reverse()\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: extractPatternSource(stepDefinition.pattern),\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 extractPatternSource(pattern: string | RegExp) {\n if (pattern instanceof RegExp) {\n return pattern.flags ? pattern.toString() : pattern.source\n }\n return pattern\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[\n [\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n HookType.BEFORE_TEST_CASE,\n ] as const,\n [\n supportCodeLibrary.afterTestCaseHookDefinitions,\n HookType.AFTER_TEST_CASE,\n ] as const,\n ].forEach(([hooks, type]) => {\n hooks.forEach((hook) => {\n eventBroadcaster.emit('envelope', {\n hook: {\n id: hook.id,\n type,\n name: hook.name,\n tagExpression: hook.tagExpression,\n sourceReference: makeSourceReference(hook),\n },\n } satisfies Envelope)\n })\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: SupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[\n [\n supportCodeLibrary.beforeTestRunHookDefinitions,\n HookType.BEFORE_TEST_RUN,\n ] as const,\n [\n supportCodeLibrary.afterTestRunHookDefinitions,\n HookType.AFTER_TEST_RUN,\n ] as const,\n ].forEach(([hooks, type]) => {\n hooks.forEach((hook) => {\n eventBroadcaster.emit('envelope', {\n hook: {\n id: hook.id,\n type,\n name: hook.name,\n sourceReference: makeSourceReference(hook),\n },\n } satisfies Envelope)\n })\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"]}
|
|
@@ -68,7 +68,7 @@ const ArgvParser = {
|
|
|
68
68
|
.option('-l, --loader <NODE_MODULE>', 'module specifier(s) for loaders to be registered ahead of loading support code', ArgvParser.collect)
|
|
69
69
|
.option('--language <ISO 639-1>', 'provide the default language for feature files')
|
|
70
70
|
.option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect)
|
|
71
|
-
.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')
|
|
71
|
+
.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined`, `reverse` or `random`')
|
|
72
72
|
.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
|
|
73
73
|
.option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', (val) => ArgvParser.validateCountOption(val, '--parallel'))
|
|
74
74
|
.option('--publish', 'Publish a report to https://reports.cucumber.io')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,wCAAoC;AACpC,kDAAoD;AAkBpD,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;QACvB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI,CAAC;gBACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;YACxE,CAAC;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,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AChC,0DAA0D,EAC1D,UAAU,CAAC,OAAO,CACnB;aACA,MAAM,CACL,6BAA6B,EAC7B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACxD;aACA,MAAM,CACL,iCAAiC,EACjC;wDACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,uBAAuB,EACvB,wDAAwD,CACzD;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACpC,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport { version } from '../version'\nimport { documentation } from '../formatter/builtin'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .allowExcessArguments(true)\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Object.entries(documentation).reduce(\n (previous, [key, description]) =>\n previous + ` ${key}: ${description}\\n`,\n ''\n ),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option(\n '--shard <INDEX/TOTAL>',\n 'run shard INDEX of TOTAL shards. The index starts at 1'\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,wCAAoC;AACpC,kDAAoD;AAkBpD,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;QACvB,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI,CAAC;gBACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;YACxE,CAAC;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CA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CACL,gCAAgC,EAChC,0DAA0D,EAC1D,UAAU,CAAC,OAAO,CACnB;aACA,MAAM,CACL,6BAA6B,EAC7B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACxD;aACA,MAAM,CACL,iCAAiC,EACjC;wDACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,uBAAuB,EACvB,wDAAwD,CACzD;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACpC,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport { version } from '../version'\nimport { documentation } from '../formatter/builtin'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .allowExcessArguments(true)\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Object.entries(documentation).reduce(\n (previous, [key, description]) =>\n previous + ` ${key}: ${description}\\n`,\n ''\n ),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined`, `reverse` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option(\n '--shard <INDEX/TOTAL>',\n 'run shard INDEX of TOTAL shards. The index starts at 1'\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
package/lib/filter/types.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { GherkinDocument, Location, Pickle } from '@cucumber/messages';
|
|
|
3
3
|
* The ordering strategy for pickles
|
|
4
4
|
* @public
|
|
5
5
|
* @example "defined"
|
|
6
|
+
* @example "reverse"
|
|
6
7
|
* @example "random"
|
|
7
8
|
* @example "random:234119"
|
|
8
9
|
*/
|
|
9
|
-
export type IPickleOrder = 'defined' | 'random' | `random:${string}`;
|
|
10
|
+
export type IPickleOrder = 'defined' | 'reverse' | 'random' | `random:${string}`;
|
|
10
11
|
export interface IFilterablePickle {
|
|
11
12
|
pickle: Pickle;
|
|
12
13
|
gherkinDocument: GherkinDocument;
|
package/lib/filter/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GherkinDocument, Location, Pickle } from '@cucumber/messages'\n\n/**\n * The ordering strategy for pickles\n * @public\n * @example \"defined\"\n * @example \"random\"\n * @example \"random:234119\"\n */\nexport type IPickleOrder = 'defined' | 'random' | `random:${string}`\n\nexport interface IFilterablePickle {\n pickle: Pickle\n gherkinDocument: GherkinDocument\n location: Location\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import { GherkinDocument, Location, Pickle } from '@cucumber/messages'\n\n/**\n * The ordering strategy for pickles\n * @public\n * @example \"defined\"\n * @example \"reverse\"\n * @example \"random\"\n * @example \"random:234119\"\n */\nexport type IPickleOrder = 'defined' | 'reverse' | 'random' | `random:${string}`\n\nexport interface IFilterablePickle {\n pickle: Pickle\n gherkinDocument: GherkinDocument\n location: Location\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export default class StepDefinitionSnippetBuilder {
|
|
|
15
15
|
private readonly cucumberExpressionGenerator;
|
|
16
16
|
constructor({ snippetSyntax, parameterTypeRegistry, }: INewStepDefinitionSnippetBuilderOptions);
|
|
17
17
|
build({ keywordType, pickleStep }: IBuildRequest): string;
|
|
18
|
+
buildMultiple({ keywordType, pickleStep }: IBuildRequest): string[];
|
|
18
19
|
getFunctionName(keywordType: KeywordType): string;
|
|
19
20
|
getStepParameterNames(step: messages.PickleStep): string[];
|
|
20
21
|
}
|
|
@@ -23,6 +23,20 @@ class StepDefinitionSnippetBuilder {
|
|
|
23
23
|
stepParameterNames,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
buildMultiple({ keywordType, pickleStep }) {
|
|
27
|
+
const comment = 'Write code here that turns the phrase above into concrete actions';
|
|
28
|
+
const functionName = this.getFunctionName(keywordType);
|
|
29
|
+
const generatedExpressions = this.cucumberExpressionGenerator.generateExpressions(pickleStep.text);
|
|
30
|
+
const stepParameterNames = this.getStepParameterNames(pickleStep);
|
|
31
|
+
return generatedExpressions.map((generatedExpression) => {
|
|
32
|
+
return this.snippetSyntax.build({
|
|
33
|
+
comment,
|
|
34
|
+
functionName,
|
|
35
|
+
generatedExpressions: [generatedExpression],
|
|
36
|
+
stepParameterNames,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
26
40
|
getFunctionName(keywordType) {
|
|
27
41
|
switch (keywordType) {
|
|
28
42
|
case helpers_1.KeywordType.Event:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/step_definition_snippet_builder/index.ts"],"names":[],"mappings":";;AAAA,yEAGuC;AAEvC,wCAAwC;AACxC,yDAAwD;AACxD,uDAAmD;AAanD,MAAqB,4BAA4B;IAC9B,aAAa,CAAgB;IAC7B,2BAA2B,CAA6B;IAEzE,YAAY,EACV,aAAa,EACb,qBAAqB,GACmB;QACxC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,2BAA2B,GAAG,IAAI,kDAA2B,CAChE,GAAG,EAAE,CAAC,qBAAqB,CAAC,cAAc,CAC3C,CAAA;IACH,CAAC;IAED,KAAK,CAAC,EAAE,WAAW,EAAE,UAAU,EAAiB;QAC9C,MAAM,OAAO,GACX,mEAAmE,CAAA;QACrE,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;QACtD,MAAM,oBAAoB,GACxB,IAAI,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACvE,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QACjE,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAC9B,OAAO;YACP,YAAY;YACZ,oBAAoB;YACpB,kBAAkB;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,WAAwB;QACtC,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,qBAAW,CAAC,KAAK;gBACpB,OAAO,MAAM,CAAA;YACf,KAAK,qBAAW,CAAC,OAAO;gBACtB,OAAO,MAAM,CAAA;YACf,KAAK,qBAAW,CAAC,YAAY;gBAC3B,OAAO,OAAO,CAAA;QAClB,CAAC;IACH,CAAC;IAED,qBAAqB,CAAC,IAAyB;QAC7C,IAAI,IAAA,6BAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,MAAM,YAAY,GAAG,IAAA,kCAAiB,EAAC,IAAI,CAAC,QAAQ,EAAE;gBACpD,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW;gBAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW;aAC7B,CAAC,CAAA;YACF,OAAO,CAAC,YAAY,CAAC,CAAA;QACvB,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/step_definition_snippet_builder/index.ts"],"names":[],"mappings":";;AAAA,yEAGuC;AAEvC,wCAAwC;AACxC,yDAAwD;AACxD,uDAAmD;AAanD,MAAqB,4BAA4B;IAC9B,aAAa,CAAgB;IAC7B,2BAA2B,CAA6B;IAEzE,YAAY,EACV,aAAa,EACb,qBAAqB,GACmB;QACxC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,2BAA2B,GAAG,IAAI,kDAA2B,CAChE,GAAG,EAAE,CAAC,qBAAqB,CAAC,cAAc,CAC3C,CAAA;IACH,CAAC;IAED,KAAK,CAAC,EAAE,WAAW,EAAE,UAAU,EAAiB;QAC9C,MAAM,OAAO,GACX,mEAAmE,CAAA;QACrE,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;QACtD,MAAM,oBAAoB,GACxB,IAAI,CAAC,2BAA2B,CAAC,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACvE,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QACjE,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAC9B,OAAO;YACP,YAAY;YACZ,oBAAoB;YACpB,kBAAkB;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,WAAW,EAA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nimport * as messages from '@cucumber/messages'\nimport { KeywordType } from '../helpers'\nimport { parseStepArgument } from '../../step_arguments'\nimport { doesHaveValue } from '../../value_checker'\nimport { ISnippetSnytax } from './snippet_syntax'\n\nexport interface INewStepDefinitionSnippetBuilderOptions {\n snippetSyntax: ISnippetSnytax\n parameterTypeRegistry: ParameterTypeRegistry\n}\n\nexport interface IBuildRequest {\n keywordType: KeywordType\n pickleStep: messages.PickleStep\n}\n\nexport default class StepDefinitionSnippetBuilder {\n private readonly snippetSyntax: ISnippetSnytax\n private readonly cucumberExpressionGenerator: CucumberExpressionGenerator\n\n constructor({\n snippetSyntax,\n parameterTypeRegistry,\n }: INewStepDefinitionSnippetBuilderOptions) {\n this.snippetSyntax = snippetSyntax\n this.cucumberExpressionGenerator = new CucumberExpressionGenerator(\n () => parameterTypeRegistry.parameterTypes\n )\n }\n\n build({ keywordType, pickleStep }: IBuildRequest): string {\n const comment =\n 'Write code here that turns the phrase above into concrete actions'\n const functionName = this.getFunctionName(keywordType)\n const generatedExpressions =\n this.cucumberExpressionGenerator.generateExpressions(pickleStep.text)\n const stepParameterNames = this.getStepParameterNames(pickleStep)\n return this.snippetSyntax.build({\n comment,\n functionName,\n generatedExpressions,\n stepParameterNames,\n })\n }\n\n buildMultiple({ keywordType, pickleStep }: IBuildRequest): string[] {\n const comment =\n 'Write code here that turns the phrase above into concrete actions'\n const functionName = this.getFunctionName(keywordType)\n const generatedExpressions =\n this.cucumberExpressionGenerator.generateExpressions(pickleStep.text)\n const stepParameterNames = this.getStepParameterNames(pickleStep)\n return generatedExpressions.map((generatedExpression) => {\n return this.snippetSyntax.build({\n comment,\n functionName,\n generatedExpressions: [generatedExpression],\n stepParameterNames,\n })\n })\n }\n\n getFunctionName(keywordType: KeywordType): string {\n switch (keywordType) {\n case KeywordType.Event:\n return 'When'\n case KeywordType.Outcome:\n return 'Then'\n case KeywordType.Precondition:\n return 'Given'\n }\n }\n\n getStepParameterNames(step: messages.PickleStep): string[] {\n if (doesHaveValue(step.argument)) {\n const argumentName = parseStepArgument(step.argument, {\n dataTable: () => 'dataTable',\n docString: () => 'docString',\n })\n return [argumentName]\n }\n return []\n }\n}\n"]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import Definition from './definition';
|
|
1
|
+
import Definition, { IDefinitionParameters, IDefinitionOptions } from './definition';
|
|
2
|
+
export interface ITestRunHookDefinitionOptions extends IDefinitionOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
2
5
|
export default class TestRunHookDefinition extends Definition {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
constructor(data: IDefinitionParameters<ITestRunHookDefinitionOptions>);
|
|
3
8
|
}
|
|
@@ -5,6 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const definition_1 = __importDefault(require("./definition"));
|
|
7
7
|
class TestRunHookDefinition extends definition_1.default {
|
|
8
|
+
name;
|
|
9
|
+
constructor(data) {
|
|
10
|
+
super(data);
|
|
11
|
+
this.name = data.options.name;
|
|
12
|
+
}
|
|
8
13
|
}
|
|
9
14
|
exports.default = TestRunHookDefinition;
|
|
10
15
|
//# sourceMappingURL=test_run_hook_definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_run_hook_definition.js","sourceRoot":"","sources":["../../src/models/test_run_hook_definition.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"test_run_hook_definition.js","sourceRoot":"","sources":["../../src/models/test_run_hook_definition.ts"],"names":[],"mappings":";;;;;AAAA,8DAGqB;AAMrB,MAAqB,qBAAsB,SAAQ,oBAAU;IAC3C,IAAI,CAAQ;IAE5B,YAAY,IAA0D;QACpE,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;IAC/B,CAAC;CACF;AAPD,wCAOC","sourcesContent":["import Definition, {\n IDefinitionParameters,\n IDefinitionOptions,\n} from './definition'\n\nexport interface ITestRunHookDefinitionOptions extends IDefinitionOptions {\n name?: string\n}\n\nexport default class TestRunHookDefinition extends Definition {\n public readonly name: string\n\n constructor(data: IDefinitionParameters<ITestRunHookDefinitionOptions>) {\n super(data)\n this.name = data.options.name\n }\n}\n"]}
|
|
@@ -5,11 +5,12 @@ import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
|
5
5
|
import { RuntimeAdapter } from './types';
|
|
6
6
|
import { Runtime } from './index';
|
|
7
7
|
export declare class Coordinator implements Runtime {
|
|
8
|
+
private testRunStartedId;
|
|
8
9
|
private eventBroadcaster;
|
|
9
10
|
private newId;
|
|
10
11
|
private sourcedPickles;
|
|
11
12
|
private supportCodeLibrary;
|
|
12
13
|
private adapter;
|
|
13
|
-
constructor(eventBroadcaster: EventEmitter, newId: IdGenerator.NewId, sourcedPickles: ReadonlyArray<SourcedPickle>, supportCodeLibrary: SupportCodeLibrary, adapter: RuntimeAdapter);
|
|
14
|
+
constructor(testRunStartedId: string, eventBroadcaster: EventEmitter, newId: IdGenerator.NewId, sourcedPickles: ReadonlyArray<SourcedPickle>, supportCodeLibrary: SupportCodeLibrary, adapter: RuntimeAdapter);
|
|
14
15
|
run(): Promise<boolean>;
|
|
15
16
|
}
|
|
@@ -4,12 +4,14 @@ exports.Coordinator = void 0;
|
|
|
4
4
|
const assemble_1 = require("../assemble");
|
|
5
5
|
const stopwatch_1 = require("./stopwatch");
|
|
6
6
|
class Coordinator {
|
|
7
|
+
testRunStartedId;
|
|
7
8
|
eventBroadcaster;
|
|
8
9
|
newId;
|
|
9
10
|
sourcedPickles;
|
|
10
11
|
supportCodeLibrary;
|
|
11
12
|
adapter;
|
|
12
|
-
constructor(eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter) {
|
|
13
|
+
constructor(testRunStartedId, eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter) {
|
|
14
|
+
this.testRunStartedId = testRunStartedId;
|
|
13
15
|
this.eventBroadcaster = eventBroadcaster;
|
|
14
16
|
this.newId = newId;
|
|
15
17
|
this.sourcedPickles = sourcedPickles;
|
|
@@ -17,18 +19,17 @@ class Coordinator {
|
|
|
17
19
|
this.adapter = adapter;
|
|
18
20
|
}
|
|
19
21
|
async run() {
|
|
20
|
-
const testRunStartedId = this.newId();
|
|
21
22
|
this.eventBroadcaster.emit('envelope', {
|
|
22
23
|
testRunStarted: {
|
|
23
|
-
id: testRunStartedId,
|
|
24
|
+
id: this.testRunStartedId,
|
|
24
25
|
timestamp: (0, stopwatch_1.timestamp)(),
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
|
-
const assembledTestCases = await (0, assemble_1.assembleTestCases)(testRunStartedId, this.eventBroadcaster, this.newId, this.sourcedPickles, this.supportCodeLibrary);
|
|
28
|
+
const assembledTestCases = await (0, assemble_1.assembleTestCases)(this.testRunStartedId, this.eventBroadcaster, this.newId, this.sourcedPickles, this.supportCodeLibrary);
|
|
28
29
|
const success = await this.adapter.run(assembledTestCases);
|
|
29
30
|
this.eventBroadcaster.emit('envelope', {
|
|
30
31
|
testRunFinished: {
|
|
31
|
-
testRunStartedId,
|
|
32
|
+
testRunStartedId: this.testRunStartedId,
|
|
32
33
|
timestamp: (0, stopwatch_1.timestamp)(),
|
|
33
34
|
success,
|
|
34
35
|
},
|
|
@@ -1 +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;
|
|
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;IACA;IANV,YACU,gBAAwB,EACxB,gBAA8B,EAC9B,KAAwB,EACxB,cAA4C,EAC5C,kBAAsC,EACtC,OAAuB;QALvB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,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,EAAE,EAAE,IAAI,CAAC,gBAAgB;gBACzB,SAAS,EAAE,IAAA,qBAAS,GAAE;aACvB;SACiB,CAAC,CAAA;QAErB,MAAM,kBAAkB,GAAG,MAAM,IAAA,4BAAiB,EAChD,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,kBAAkB,CACxB,CAAA;QAED,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,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,SAAS,EAAE,IAAA,qBAAS,GAAE;gBACtB,OAAO;aACR;SACiB,CAAC,CAAA;QAErB,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAtCD,kCAsCC","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 testRunStartedId: string,\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 id: this.testRunStartedId,\n timestamp: timestamp(),\n },\n } satisfies Envelope)\n\n const assembledTestCases = await assembleTestCases(\n this.testRunStartedId,\n this.eventBroadcaster,\n this.newId,\n this.sourcedPickles,\n this.supportCodeLibrary\n )\n\n const success = await this.adapter.run(assembledTestCases)\n\n this.eventBroadcaster.emit('envelope', {\n testRunFinished: {\n testRunStartedId: this.testRunStartedId,\n timestamp: timestamp(),\n success,\n },\n } satisfies Envelope)\n\n return success\n }\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { IdGenerator } from '@cucumber/messages';
|
|
3
3
|
import { IRunOptionsRuntime } from '../api';
|
|
4
|
-
import { ILogger } from '../environment';
|
|
4
|
+
import { ILogger, IRunEnvironment } from '../environment';
|
|
5
5
|
import { SourcedPickle } from '../assemble';
|
|
6
6
|
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
|
-
import {
|
|
7
|
+
import { FormatOptions } from '../formatter';
|
|
8
8
|
import { Runtime } from './types';
|
|
9
|
-
export declare function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, }: {
|
|
9
|
+
export declare function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, snippetOptions, }: {
|
|
10
10
|
environment: IRunEnvironment;
|
|
11
11
|
logger: ILogger;
|
|
12
12
|
eventBroadcaster: EventEmitter;
|
|
@@ -14,4 +14,5 @@ export declare function makeRuntime({ environment, logger, eventBroadcaster, sou
|
|
|
14
14
|
sourcedPickles: ReadonlyArray<SourcedPickle>;
|
|
15
15
|
supportCodeLibrary: SupportCodeLibrary;
|
|
16
16
|
options: IRunOptionsRuntime;
|
|
17
|
+
snippetOptions: Pick<FormatOptions, 'snippetInterface' | 'snippetSyntax'>;
|
|
17
18
|
}): Promise<Runtime>;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.makeRuntime = makeRuntime;
|
|
7
|
+
const builder_1 = __importDefault(require("../formatter/builder"));
|
|
4
8
|
const adapter_1 = require("./parallel/adapter");
|
|
5
9
|
const adapter_2 = require("./serial/adapter");
|
|
6
10
|
const coordinator_1 = require("./coordinator");
|
|
7
|
-
async function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, }) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
async function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, snippetOptions, }) {
|
|
12
|
+
const testRunStartedId = newId();
|
|
13
|
+
const adapter = await makeAdapter(options, snippetOptions, testRunStartedId, environment, logger, eventBroadcaster, supportCodeLibrary, newId);
|
|
14
|
+
return new coordinator_1.Coordinator(testRunStartedId, eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter);
|
|
15
|
+
}
|
|
16
|
+
async function makeAdapter(options, snippetOptions, testRunStartedId, environment, logger, eventBroadcaster, supportCodeLibrary, newId) {
|
|
17
|
+
if (options.parallel > 0) {
|
|
18
|
+
return new adapter_1.ChildProcessAdapter(testRunStartedId, environment, logger, eventBroadcaster, options, snippetOptions, supportCodeLibrary);
|
|
19
|
+
}
|
|
20
|
+
const snippetBuilder = await builder_1.default.getStepDefinitionSnippetBuilder({
|
|
21
|
+
cwd: environment.cwd,
|
|
22
|
+
snippetInterface: snippetOptions.snippetInterface,
|
|
23
|
+
snippetSyntax: snippetOptions.snippetSyntax,
|
|
24
|
+
supportCodeLibrary,
|
|
25
|
+
});
|
|
26
|
+
return new adapter_2.InProcessAdapter(testRunStartedId, eventBroadcaster, newId, options, supportCodeLibrary, snippetBuilder);
|
|
12
27
|
}
|
|
13
28
|
//# sourceMappingURL=make_runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make_runtime.js","sourceRoot":"","sources":["../../src/runtime/make_runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"make_runtime.js","sourceRoot":"","sources":["../../src/runtime/make_runtime.ts"],"names":[],"mappings":";;;;;AAaA,kCAsCC;AA7CD,mEAAmD;AAGnD,gDAAwD;AACxD,8CAAmD;AACnD,+CAA2C;AAEpC,KAAK,UAAU,WAAW,CAAC,EAChC,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,OAAO,EACP,cAAc,GAUf;IACC,MAAM,gBAAgB,GAAG,KAAK,EAAE,CAAA;IAChC,MAAM,OAAO,GAAG,MAAM,WAAW,CAC/B,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,CACN,CAAA;IACD,OAAO,IAAI,yBAAW,CACpB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,OAAO,CACR,CAAA;AACH,CAAC;AAED,KAAK,UAAU,WAAW,CACxB,OAA2B,EAC3B,cAAyE,EACzE,gBAAwB,EACxB,WAA4B,EAC5B,MAAe,EACf,gBAA8B,EAC9B,kBAAsC,EACtC,KAAmB;IAEnB,IAAI,OAAO,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,6BAAmB,CAC5B,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,kBAAkB,CACnB,CAAA;IACH,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,iBAAgB,CAAC,+BAA+B,CAC3E;QACE,GAAG,EAAE,WAAW,CAAC,GAAG;QACpB,gBAAgB,EAAE,cAAc,CAAC,gBAAgB;QACjD,aAAa,EAAE,cAAc,CAAC,aAAa;QAC3C,kBAAkB;KACnB,CACF,CAAA;IACD,OAAO,IAAI,0BAAgB,CACzB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,EAClB,cAAc,CACf,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IRunOptionsRuntime } from '../api'\nimport { ILogger, IRunEnvironment } from '../environment'\nimport { SourcedPickle } from '../assemble'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport FormatterBuilder from '../formatter/builder'\nimport { FormatOptions } from '../formatter'\nimport { Runtime } from './types'\nimport { ChildProcessAdapter } from './parallel/adapter'\nimport { InProcessAdapter } from './serial/adapter'\nimport { Coordinator } from './coordinator'\n\nexport async function makeRuntime({\n environment,\n logger,\n eventBroadcaster,\n sourcedPickles,\n newId,\n supportCodeLibrary,\n options,\n snippetOptions,\n}: {\n environment: IRunEnvironment\n logger: ILogger\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n sourcedPickles: ReadonlyArray<SourcedPickle>\n supportCodeLibrary: SupportCodeLibrary\n options: IRunOptionsRuntime\n snippetOptions: Pick<FormatOptions, 'snippetInterface' | 'snippetSyntax'>\n}): Promise<Runtime> {\n const testRunStartedId = newId()\n const adapter = await makeAdapter(\n options,\n snippetOptions,\n testRunStartedId,\n environment,\n logger,\n eventBroadcaster,\n supportCodeLibrary,\n newId\n )\n return new Coordinator(\n testRunStartedId,\n eventBroadcaster,\n newId,\n sourcedPickles,\n supportCodeLibrary,\n adapter\n )\n}\n\nasync function makeAdapter(\n options: IRunOptionsRuntime,\n snippetOptions: Pick<FormatOptions, 'snippetInterface' | 'snippetSyntax'>,\n testRunStartedId: string,\n environment: IRunEnvironment,\n logger: ILogger,\n eventBroadcaster: EventEmitter,\n supportCodeLibrary: SupportCodeLibrary,\n newId: () => string\n) {\n if (options.parallel > 0) {\n return new ChildProcessAdapter(\n testRunStartedId,\n environment,\n logger,\n eventBroadcaster,\n options,\n snippetOptions,\n supportCodeLibrary\n )\n }\n const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder(\n {\n cwd: environment.cwd,\n snippetInterface: snippetOptions.snippetInterface,\n snippetSyntax: snippetOptions.snippetSyntax,\n supportCodeLibrary,\n }\n )\n return new InProcessAdapter(\n testRunStartedId,\n eventBroadcaster,\n newId,\n options,\n supportCodeLibrary,\n snippetBuilder\n )\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IdGenerator, PickleStep, Suggestion } from '@cucumber/messages';
|
|
2
|
+
import StepDefinitionSnippetBuilder from '../formatter/step_definition_snippet_builder';
|
|
3
|
+
export declare function makeSuggestion({ newId, snippetBuilder, pickleStep, }: {
|
|
4
|
+
newId: IdGenerator.NewId;
|
|
5
|
+
snippetBuilder: StepDefinitionSnippetBuilder;
|
|
6
|
+
pickleStep: PickleStep;
|
|
7
|
+
}): Suggestion;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSuggestion = makeSuggestion;
|
|
4
|
+
const messages_1 = require("@cucumber/messages");
|
|
5
|
+
const helpers_1 = require("../formatter/helpers");
|
|
6
|
+
function mapPickleStepTypeToKeywordType(type) {
|
|
7
|
+
switch (type) {
|
|
8
|
+
case messages_1.PickleStepType.CONTEXT:
|
|
9
|
+
return helpers_1.KeywordType.Precondition;
|
|
10
|
+
case messages_1.PickleStepType.ACTION:
|
|
11
|
+
return helpers_1.KeywordType.Event;
|
|
12
|
+
case messages_1.PickleStepType.OUTCOME:
|
|
13
|
+
return helpers_1.KeywordType.Outcome;
|
|
14
|
+
default:
|
|
15
|
+
return helpers_1.KeywordType.Precondition;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function makeSuggestion({ newId, snippetBuilder, pickleStep, }) {
|
|
19
|
+
const keywordType = mapPickleStepTypeToKeywordType(pickleStep.type);
|
|
20
|
+
const codes = snippetBuilder.buildMultiple({ keywordType, pickleStep });
|
|
21
|
+
const snippets = codes.map((code) => ({
|
|
22
|
+
code,
|
|
23
|
+
language: 'javascript',
|
|
24
|
+
}));
|
|
25
|
+
return {
|
|
26
|
+
id: newId(),
|
|
27
|
+
pickleStepId: pickleStep.id,
|
|
28
|
+
snippets,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=make_suggestion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make_suggestion.js","sourceRoot":"","sources":["../../src/runtime/make_suggestion.ts"],"names":[],"mappings":";;AAsBA,wCAqBC;AA3CD,iDAK2B;AAE3B,kDAAkD;AAElD,SAAS,8BAA8B,CAAC,IAAqB;IAC3D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,yBAAc,CAAC,OAAO;YACzB,OAAO,qBAAW,CAAC,YAAY,CAAA;QACjC,KAAK,yBAAc,CAAC,MAAM;YACxB,OAAO,qBAAW,CAAC,KAAK,CAAA;QAC1B,KAAK,yBAAc,CAAC,OAAO;YACzB,OAAO,qBAAW,CAAC,OAAO,CAAA;QAC5B;YACE,OAAO,qBAAW,CAAC,YAAY,CAAA;IACnC,CAAC;AACH,CAAC;AAED,SAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,cAAc,EACd,UAAU,GAKX;IACC,MAAM,WAAW,GAAG,8BAA8B,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnE,MAAM,KAAK,GAAG,cAAc,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;IACvE,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI;QACJ,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC,CAAA;IAEH,OAAO;QACL,EAAE,EAAE,KAAK,EAAE;QACX,YAAY,EAAE,UAAU,CAAC,EAAE;QAC3B,QAAQ;KACT,CAAA;AACH,CAAC","sourcesContent":["import {\n IdGenerator,\n PickleStep,\n PickleStepType,\n Suggestion,\n} from '@cucumber/messages'\nimport StepDefinitionSnippetBuilder from '../formatter/step_definition_snippet_builder'\nimport { KeywordType } from '../formatter/helpers'\n\nfunction mapPickleStepTypeToKeywordType(type?: PickleStepType): KeywordType {\n switch (type) {\n case PickleStepType.CONTEXT:\n return KeywordType.Precondition\n case PickleStepType.ACTION:\n return KeywordType.Event\n case PickleStepType.OUTCOME:\n return KeywordType.Outcome\n default:\n return KeywordType.Precondition\n }\n}\n\nexport function makeSuggestion({\n newId,\n snippetBuilder,\n pickleStep,\n}: {\n newId: IdGenerator.NewId\n snippetBuilder: StepDefinitionSnippetBuilder\n pickleStep: PickleStep\n}): Suggestion {\n const keywordType = mapPickleStepTypeToKeywordType(pickleStep.type)\n const codes = snippetBuilder.buildMultiple({ keywordType, pickleStep })\n const snippets = codes.map((code) => ({\n code,\n language: 'javascript',\n }))\n\n return {\n id: newId(),\n pickleStepId: pickleStep.id,\n snippets,\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import { AssembledTestCase } from '../../assemble';
|
|
|
5
5
|
import { ILogger, IRunEnvironment } from '../../environment';
|
|
6
6
|
import { RuntimeAdapter } from '../types';
|
|
7
7
|
import { IRunOptionsRuntime } from '../../api';
|
|
8
|
+
import { FormatOptions } from '../../formatter';
|
|
8
9
|
import { WorkerToCoordinatorEvent } from './types';
|
|
9
10
|
declare const enum WorkerState {
|
|
10
11
|
'idle' = 0,
|
|
@@ -22,10 +23,12 @@ interface WorkPlacement {
|
|
|
22
23
|
item: AssembledTestCase;
|
|
23
24
|
}
|
|
24
25
|
export declare class ChildProcessAdapter implements RuntimeAdapter {
|
|
26
|
+
private readonly testRunStartedId;
|
|
25
27
|
private readonly environment;
|
|
26
28
|
private readonly logger;
|
|
27
29
|
private readonly eventBroadcaster;
|
|
28
30
|
private readonly options;
|
|
31
|
+
private readonly snippetOptions;
|
|
29
32
|
private readonly supportCodeLibrary;
|
|
30
33
|
private idleInterventions;
|
|
31
34
|
private failing;
|
|
@@ -33,7 +36,7 @@ export declare class ChildProcessAdapter implements RuntimeAdapter {
|
|
|
33
36
|
private todo;
|
|
34
37
|
private readonly inProgress;
|
|
35
38
|
private readonly workers;
|
|
36
|
-
constructor(environment: IRunEnvironment, logger: ILogger, eventBroadcaster: EventEmitter, options: IRunOptionsRuntime, supportCodeLibrary: SupportCodeLibrary);
|
|
39
|
+
constructor(testRunStartedId: string, environment: IRunEnvironment, logger: ILogger, eventBroadcaster: EventEmitter, options: IRunOptionsRuntime, snippetOptions: Pick<FormatOptions, 'snippetInterface' | 'snippetSyntax'>, supportCodeLibrary: SupportCodeLibrary);
|
|
37
40
|
parseWorkerMessage(worker: ManagedWorker, message: WorkerToCoordinatorEvent): void;
|
|
38
41
|
awakenWorkers(triggeringWorker: ManagedWorker): void;
|
|
39
42
|
startWorker(id: string, total: number): void;
|
|
@@ -8,10 +8,12 @@ const node_child_process_1 = require("node:child_process");
|
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const runWorkerPath = node_path_1.default.resolve(__dirname, 'run_worker.js');
|
|
10
10
|
class ChildProcessAdapter {
|
|
11
|
+
testRunStartedId;
|
|
11
12
|
environment;
|
|
12
13
|
logger;
|
|
13
14
|
eventBroadcaster;
|
|
14
15
|
options;
|
|
16
|
+
snippetOptions;
|
|
15
17
|
supportCodeLibrary;
|
|
16
18
|
idleInterventions = 0;
|
|
17
19
|
failing = false;
|
|
@@ -19,11 +21,13 @@ class ChildProcessAdapter {
|
|
|
19
21
|
todo = [];
|
|
20
22
|
inProgress = {};
|
|
21
23
|
workers = {};
|
|
22
|
-
constructor(environment, logger, eventBroadcaster, options, supportCodeLibrary) {
|
|
24
|
+
constructor(testRunStartedId, environment, logger, eventBroadcaster, options, snippetOptions, supportCodeLibrary) {
|
|
25
|
+
this.testRunStartedId = testRunStartedId;
|
|
23
26
|
this.environment = environment;
|
|
24
27
|
this.logger = logger;
|
|
25
28
|
this.eventBroadcaster = eventBroadcaster;
|
|
26
29
|
this.options = options;
|
|
30
|
+
this.snippetOptions = snippetOptions;
|
|
27
31
|
this.supportCodeLibrary = supportCodeLibrary;
|
|
28
32
|
}
|
|
29
33
|
parseWorkerMessage(worker, message) {
|
|
@@ -81,13 +85,17 @@ class ChildProcessAdapter {
|
|
|
81
85
|
});
|
|
82
86
|
worker.process.send({
|
|
83
87
|
type: 'INITIALIZE',
|
|
88
|
+
testRunStartedId: this.testRunStartedId,
|
|
84
89
|
supportCodeCoordinates: this.supportCodeLibrary.originalCoordinates,
|
|
85
90
|
supportCodeIds: {
|
|
86
91
|
stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map((s) => s.id),
|
|
87
92
|
beforeTestCaseHookDefinitionIds: this.supportCodeLibrary.beforeTestCaseHookDefinitions.map((h) => h.id),
|
|
88
93
|
afterTestCaseHookDefinitionIds: this.supportCodeLibrary.afterTestCaseHookDefinitions.map((h) => h.id),
|
|
94
|
+
beforeTestRunHookDefinitionIds: this.supportCodeLibrary.beforeTestRunHookDefinitions.map((h) => h.id),
|
|
95
|
+
afterTestRunHookDefinitionIds: this.supportCodeLibrary.afterTestRunHookDefinitions.map((h) => h.id),
|
|
89
96
|
},
|
|
90
97
|
options: this.options,
|
|
98
|
+
snippetOptions: this.snippetOptions,
|
|
91
99
|
});
|
|
92
100
|
}
|
|
93
101
|
onWorkerProcessClose(exitCode) {
|