@cucumber/cucumber 10.0.0 → 10.1.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.
Files changed (70) hide show
  1. package/README.md +2 -2
  2. package/lib/api/gherkin.d.ts +5 -13
  3. package/lib/api/gherkin.js +6 -26
  4. package/lib/api/gherkin.js.map +1 -1
  5. package/lib/api/load_sources.js +16 -9
  6. package/lib/api/load_sources.js.map +1 -1
  7. package/lib/api/load_support.js +11 -4
  8. package/lib/api/load_support.js.map +1 -1
  9. package/lib/api/plugins.d.ts +4 -2
  10. package/lib/api/plugins.js +19 -8
  11. package/lib/api/plugins.js.map +1 -1
  12. package/lib/api/run_cucumber.js +19 -13
  13. package/lib/api/run_cucumber.js.map +1 -1
  14. package/lib/cli/run.js +1 -2
  15. package/lib/cli/run.js.map +1 -1
  16. package/lib/configuration/types.d.ts +2 -1
  17. package/lib/configuration/types.js.map +1 -1
  18. package/lib/filter/filter_plugin.d.ts +3 -0
  19. package/lib/filter/filter_plugin.js +32 -0
  20. package/lib/filter/filter_plugin.js.map +1 -0
  21. package/lib/filter/index.d.ts +3 -0
  22. package/lib/filter/index.js +20 -0
  23. package/lib/filter/index.js.map +1 -0
  24. package/lib/filter/types.d.ts +6 -0
  25. package/lib/filter/types.js +3 -0
  26. package/lib/filter/types.js.map +1 -0
  27. package/lib/index.d.ts +2 -2
  28. package/lib/paths/index.d.ts +2 -0
  29. package/lib/paths/index.js +19 -0
  30. package/lib/paths/index.js.map +1 -0
  31. package/lib/paths/paths.d.ts +4 -0
  32. package/lib/{api → paths}/paths.js +9 -10
  33. package/lib/paths/paths.js.map +1 -0
  34. package/lib/paths/types.d.ts +6 -0
  35. package/lib/paths/types.js +3 -0
  36. package/lib/paths/types.js.map +1 -0
  37. package/lib/plugin/events.d.ts +2 -0
  38. package/lib/plugin/events.js +9 -0
  39. package/lib/plugin/events.js.map +1 -0
  40. package/lib/plugin/plugin_manager.d.ts +5 -6
  41. package/lib/plugin/plugin_manager.js +26 -16
  42. package/lib/plugin/plugin_manager.js.map +1 -1
  43. package/lib/plugin/types.d.ts +34 -10
  44. package/lib/plugin/types.js.map +1 -1
  45. package/lib/publish/publish_plugin.d.ts +3 -2
  46. package/lib/publish/publish_plugin.js +27 -25
  47. package/lib/publish/publish_plugin.js.map +1 -1
  48. package/lib/runtime/index.d.ts +2 -1
  49. package/lib/runtime/index.js +1 -1
  50. package/lib/runtime/index.js.map +1 -1
  51. package/lib/runtime/parallel/run_worker.js +1 -2
  52. package/lib/runtime/parallel/run_worker.js.map +1 -1
  53. package/lib/runtime/parallel/worker.js +1 -1
  54. package/lib/runtime/parallel/worker.js.map +1 -1
  55. package/lib/runtime/run_test_run_hooks.d.ts +2 -1
  56. package/lib/runtime/run_test_run_hooks.js +3 -4
  57. package/lib/runtime/run_test_run_hooks.js.map +1 -1
  58. package/lib/runtime/test_case_runner.d.ts +2 -1
  59. package/lib/runtime/test_case_runner.js +1 -1
  60. package/lib/runtime/test_case_runner.js.map +1 -1
  61. package/lib/support_code_library_builder/types.d.ts +6 -2
  62. package/lib/support_code_library_builder/types.js.map +1 -1
  63. package/lib/try_require.js +1 -3
  64. package/lib/try_require.js.map +1 -1
  65. package/lib/version.d.ts +1 -1
  66. package/lib/version.js +1 -1
  67. package/lib/version.js.map +1 -1
  68. package/package.json +13 -14
  69. package/lib/api/paths.d.ts +0 -8
  70. package/lib/api/paths.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA2B;AAC3B,2EAAgD;AAChD,kDAAqD;AACrD,oDAAgE;AAQzD,MAAM,mBAAmB,GAAG,CACjC,MAAe,EACf,cAAsB,EACtB,YAAwD,EACtC,EAAE,CACpB,MAAM;IACJ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC;IAChB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAC1B,KAAK,MAAM,cAAc,IAAI,WAAW,EAAE;YACxC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,EAAE;gBACb,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,IAAI;gBACb,qBAAqB,EAAE,IAAA,8BAAc,EACnC,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf;aACF,CAAC,CAAA;YACF,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,QAAQ,GAAG,IAAA,wBAAc,EAAC,cAAc,CAAC,CAAA;gBAC/C,MAAM,IAAI,gBAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,CAAA;AAvBM,QAAA,mBAAmB,uBAuBzB","sourcesContent":["import VError from 'verror'\nimport UserCodeRunner from '../user_code_runner'\nimport { formatLocation } from '../formatter/helpers'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\n\nexport type RunsTestRunHooks = (\n definitions: TestRunHookDefinition[],\n name: string\n) => Promise<void>\n\nexport const makeRunTestRunHooks = (\n dryRun: boolean,\n defaultTimeout: number,\n errorMessage: (name: string, location: string) => string\n): RunsTestRunHooks =>\n dryRun\n ? async () => {}\n : async (definitions, name) => {\n for (const hookDefinition of definitions) {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: null,\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new VError(error, errorMessage(name, location))\n }\n }\n }\n"]}
1
+ {"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;AACA,2EAAgD;AAChD,kDAAqD;AACrD,oDAAgE;AAQzD,MAAM,mBAAmB,GAAG,CACjC,MAAe,EACf,cAAsB,EACtB,eAA2B,EAC3B,YAAwD,EACtC,EAAE,CACpB,MAAM;IACJ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC;IAChB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAC1B,KAAK,MAAM,cAAc,IAAI,WAAW,EAAE;YACxC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,EAAE;gBACb,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE;gBACxC,qBAAqB,EAAE,IAAA,8BAAc,EACnC,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf;aACF,CAAC,CAAA;YACF,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,QAAQ,GAAG,IAAA,wBAAc,EAAC,cAAc,CAAC,CAAA;gBAC/C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;aAChE;SACF;IACH,CAAC,CAAA;AAxBM,QAAA,mBAAmB,uBAwBzB","sourcesContent":["import { JsonObject } from 'type-fest'\nimport UserCodeRunner from '../user_code_runner'\nimport { formatLocation } from '../formatter/helpers'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\n\nexport type RunsTestRunHooks = (\n definitions: TestRunHookDefinition[],\n name: string\n) => Promise<void>\n\nexport const makeRunTestRunHooks = (\n dryRun: boolean,\n defaultTimeout: number,\n worldParameters: JsonObject,\n errorMessage: (name: string, location: string) => string\n): RunsTestRunHooks =>\n dryRun\n ? async () => {}\n : async (definitions, name) => {\n for (const hookDefinition of definitions) {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: { parameters: worldParameters },\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new Error(errorMessage(name, location), { cause: error })\n }\n }\n }\n"]}
@@ -2,6 +2,7 @@
2
2
  import { EventEmitter } from 'node:events';
3
3
  import * as messages from '@cucumber/messages';
4
4
  import { IdGenerator } from '@cucumber/messages';
5
+ import { JsonObject } from 'type-fest';
5
6
  import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
6
7
  import TestCaseHookDefinition from '../models/test_case_hook_definition';
7
8
  import TestStepHookDefinition from '../models/test_step_hook_definition';
@@ -18,7 +19,7 @@ export interface INewTestCaseRunnerOptions {
18
19
  skip: boolean;
19
20
  filterStackTraces: boolean;
20
21
  supportCodeLibrary: ISupportCodeLibrary;
21
- worldParameters: any;
22
+ worldParameters: JsonObject;
22
23
  }
23
24
  export default class TestCaseRunner {
24
25
  private readonly attachmentManager;
@@ -83,7 +83,7 @@ class TestCaseRunner {
83
83
  this.world = new this.supportCodeLibrary.World({
84
84
  attach: this.attachmentManager.create.bind(this.attachmentManager),
85
85
  log: this.attachmentManager.log.bind(this.attachmentManager),
86
- parameters: this.worldParameters,
86
+ parameters: structuredClone(this.worldParameters),
87
87
  });
88
88
  this.testStepResults = [];
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA8C;AAC9C,iDAAwE;AASxE,oDAAkE;AAGlE,gEAAsC;AACtC,8EAAoD;AACpD,uCAAqD;AAgBrD,MAAqB,cAAc;IAChB,iBAAiB,CAAmB;IAC7C,wBAAwB,CAAQ;IAChC,iBAAiB,CAAQ;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C,CAAC,CAAC,CAAA;YAClE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAC7B;QACD,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,YAAY,CAClD,IAAI,CAAC,2BAA2B,EAAE,EAClC,UAAU,EACV,UAAU,CACX,CAAA;QACD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QAEtD,MAAM,eAAe,GAAG,IAAA,iCAAsB,EAAC,WAAW,CAAC,CAAA;QAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAlUD,iCAkUC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport StepDefinition from '../models/step_definition'\nimport { IStopwatch } from './stopwatch'\nimport StepRunner from './step_runner'\nimport AttachmentManager from './attachment_manager'\nimport { getAmbiguousStepException } from './helpers'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: IStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: IStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(\n ({ data, media, fileName }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n fileName,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n }\n )\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
1
+ {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAGlE,gEAAsC;AACtC,8EAAoD;AACpD,uCAAqD;AAgBrD,MAAqB,cA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C,MAAM,EACpC;YACA,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;YAClE,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAC7B;QACD,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,YAAY,CAClD,IAAI,CAAC,2BAA2B,EAAE,EAClC,UAAU,EACV,UAAU,CACX,CAAA;QACD,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QAEtD,MAAM,eAAe,GAAG,IAAA,iCAAsB,EAAC,WAAW,CAAC,CAAA;QAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AAlUD,iCAkUC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { JsonObject } from 'type-fest'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport StepDefinition from '../models/step_definition'\nimport { IStopwatch } from './stopwatch'\nimport StepRunner from './step_runner'\nimport AttachmentManager from './attachment_manager'\nimport { getAmbiguousStepException } from './helpers'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: IStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: JsonObject\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: IStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: JsonObject\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(\n ({ data, media, fileName }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n fileName,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n }\n )\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: structuredClone(this.worldParameters),\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import * as messages from '@cucumber/messages';
2
+ import { JsonObject } from 'type-fest';
2
3
  import TestCaseHookDefinition from '../models/test_case_hook_definition';
3
4
  import TestStepHookDefinition from '../models/test_step_hook_definition';
4
5
  import TestRunHookDefinition from '../models/test_run_hook_definition';
@@ -22,6 +23,9 @@ export interface ITestStepHookParameter {
22
23
  testCaseStartedId: string;
23
24
  testStepId: string;
24
25
  }
26
+ export type TestRunHookFunction = (this: {
27
+ parameters: JsonObject;
28
+ }) => any | Promise<any>;
25
29
  export type TestCaseHookFunction<WorldType> = (this: WorldType, arg: ITestCaseHookParameter) => any | Promise<any>;
26
30
  export type TestStepHookFunction<WorldType> = (this: WorldType, arg: ITestStepHookParameter) => any | Promise<any>;
27
31
  export type TestStepFunction<WorldType> = (this: WorldType, ...args: any[]) => any | Promise<any>;
@@ -58,10 +62,10 @@ export interface IDefineSupportCodeMethods {
58
62
  setWorldConstructor: (fn: any) => void;
59
63
  After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
60
64
  AfterStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
61
- AfterAll: ((code: Function) => void) & ((options: IDefineTestRunHookOptions, code: Function) => void);
65
+ AfterAll: ((code: TestRunHookFunction) => void) & ((options: IDefineTestRunHookOptions, code: TestRunHookFunction) => void);
62
66
  Before: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
63
67
  BeforeStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
64
- BeforeAll: ((code: Function) => void) & ((options: IDefineTestRunHookOptions, code: Function) => void);
68
+ BeforeAll: ((code: TestRunHookFunction) => void) & ((options: IDefineTestRunHookOptions, code: TestRunHookFunction) => void);
65
69
  Given: IDefineStep;
66
70
  Then: IDefineStep;
67
71
  When: IDefineStep;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as messages from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { IWorld } from './world'\nimport { SourcedParameterTypeRegistry } from './sourced_parameter_type_registry'\n\nexport type DefineStepPattern = string | RegExp\nexport type ParallelAssignmentValidator = (\n pickle: messages.Pickle,\n runningPickles: messages.Pickle[]\n) => boolean\nexport interface ITestCaseHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n result?: messages.TestStepResult\n willBeRetried?: boolean\n testCaseStartedId: string\n}\n\nexport interface ITestStepHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n pickleStep: messages.PickleStep\n result: messages.TestStepResult\n testCaseStartedId: string\n testStepId: string\n}\n\nexport type TestCaseHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestCaseHookParameter\n) => any | Promise<any>\n\nexport type TestStepHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestStepHookParameter\n) => any | Promise<any>\n\nexport type TestStepFunction<WorldType> = (\n this: WorldType,\n ...args: any[]\n) => any | Promise<any>\n\nexport interface IDefineStepOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IDefineTestCaseHookOptions {\n name?: string\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestStepHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestRunHookOptions {\n timeout?: number\n}\n\nexport interface IParameterTypeDefinition<T> {\n name: string\n regexp: readonly RegExp[] | readonly string[] | RegExp | string\n transformer: (...match: string[]) => T\n useForSnippets?: boolean\n preferForRegexpMatch?: boolean\n}\n\nexport type IDefineStep = (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n\nexport interface IDefineSupportCodeMethods {\n defineParameterType: (options: IParameterTypeDefinition<any>) => void\n defineStep: IDefineStep\n setDefaultTimeout: (milliseconds: number) => void\n setDefinitionFunctionWrapper: (fn: Function) => void\n setParallelCanAssign: (fn: ParallelAssignmentValidator) => void\n setWorldConstructor: (fn: any) => void\n After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n AfterStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n AfterAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Before: (<WorldType = IWorld>(\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n BeforeStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n BeforeAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Given: IDefineStep\n Then: IDefineStep\n When: IDefineStep\n}\n\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\nexport interface ISupportCodeLibrary {\n readonly originalCoordinates: ISupportCodeCoordinates\n readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly afterTestStepHookDefinitions: TestStepHookDefinition[]\n readonly afterTestRunHookDefinitions: TestRunHookDefinition[]\n readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]\n readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]\n readonly defaultTimeout: number\n readonly stepDefinitions: StepDefinition[]\n readonly undefinedParameterTypes: messages.UndefinedParameterType[]\n readonly parameterTypeRegistry: SourcedParameterTypeRegistry\n readonly World: any\n readonly parallelCanAssign: ParallelAssignmentValidator\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { JsonObject } from 'type-fest'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { IWorld } from './world'\nimport { SourcedParameterTypeRegistry } from './sourced_parameter_type_registry'\n\nexport type DefineStepPattern = string | RegExp\nexport type ParallelAssignmentValidator = (\n pickle: messages.Pickle,\n runningPickles: messages.Pickle[]\n) => boolean\nexport interface ITestCaseHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n result?: messages.TestStepResult\n willBeRetried?: boolean\n testCaseStartedId: string\n}\n\nexport interface ITestStepHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n pickleStep: messages.PickleStep\n result: messages.TestStepResult\n testCaseStartedId: string\n testStepId: string\n}\n\nexport type TestRunHookFunction = (this: {\n parameters: JsonObject\n}) => any | Promise<any>\n\nexport type TestCaseHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestCaseHookParameter\n) => any | Promise<any>\n\nexport type TestStepHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestStepHookParameter\n) => any | Promise<any>\n\nexport type TestStepFunction<WorldType> = (\n this: WorldType,\n ...args: any[]\n) => any | Promise<any>\n\nexport interface IDefineStepOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IDefineTestCaseHookOptions {\n name?: string\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestStepHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestRunHookOptions {\n timeout?: number\n}\n\nexport interface IParameterTypeDefinition<T> {\n name: string\n regexp: readonly RegExp[] | readonly string[] | RegExp | string\n transformer: (...match: string[]) => T\n useForSnippets?: boolean\n preferForRegexpMatch?: boolean\n}\n\nexport type IDefineStep = (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n\nexport interface IDefineSupportCodeMethods {\n defineParameterType: (options: IParameterTypeDefinition<any>) => void\n defineStep: IDefineStep\n setDefaultTimeout: (milliseconds: number) => void\n setDefinitionFunctionWrapper: (fn: Function) => void\n setParallelCanAssign: (fn: ParallelAssignmentValidator) => void\n setWorldConstructor: (fn: any) => void\n After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n AfterStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n AfterAll: ((code: TestRunHookFunction) => void) &\n ((options: IDefineTestRunHookOptions, code: TestRunHookFunction) => void)\n Before: (<WorldType = IWorld>(\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n BeforeStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n BeforeAll: ((code: TestRunHookFunction) => void) &\n ((options: IDefineTestRunHookOptions, code: TestRunHookFunction) => void)\n Given: IDefineStep\n Then: IDefineStep\n When: IDefineStep\n}\n\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\nexport interface ISupportCodeLibrary {\n readonly originalCoordinates: ISupportCodeCoordinates\n readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly afterTestStepHookDefinitions: TestStepHookDefinition[]\n readonly afterTestRunHookDefinitions: TestRunHookDefinition[]\n readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]\n readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]\n readonly defaultTimeout: number\n readonly stepDefinitions: StepDefinition[]\n readonly undefinedParameterTypes: messages.UndefinedParameterType[]\n readonly parameterTypeRegistry: SourcedParameterTypeRegistry\n readonly World: any\n readonly parallelCanAssign: ParallelAssignmentValidator\n}\n"]}
@@ -13,9 +13,7 @@ function tryRequire(path) {
13
13
  catch (error) {
14
14
  if (error.code === 'ERR_REQUIRE_ESM') {
15
15
  throw Error(`Cucumber expected a CommonJS module at '${path}' but found an ES module.
16
- Either change the file to CommonJS syntax or use the --import directive instead of --require.
17
-
18
- Original error message: ${error.message}`);
16
+ Either change the file to CommonJS syntax or use the --import directive instead of --require.`, { cause: error });
19
17
  }
20
18
  else {
21
19
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"try_require.js","sourceRoot":"","sources":["../src/try_require.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,UAAU,CAAC,IAAY;IAC7C,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACpC,MAAM,KAAK,CACT,2CAA2C,IAAI;;;gCAGvB,KAAK,CAAC,OAAO,EAAE,CACxC,CAAA;SACF;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC;AAfD,6BAeC","sourcesContent":["/**\n * Provides a try guarded require call that will throw a more detailed error when\n * the ERR_REQUIRE_ESM error code is encountered.\n *\n * @param {string} path File path to require from.\n */\nexport default function tryRequire(path: string) {\n try {\n return require(path)\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n throw Error(\n `Cucumber expected a CommonJS module at '${path}' but found an ES module.\n Either change the file to CommonJS syntax or use the --import directive instead of --require.\n \n Original error message: ${error.message}`\n )\n } else {\n throw error\n }\n }\n}\n"]}
1
+ {"version":3,"file":"try_require.js","sourceRoot":"","sources":["../src/try_require.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,UAAU,CAAC,IAAY;IAC7C,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACpC,MAAM,KAAK,CACT,2CAA2C,IAAI;oGAC6C,EAC5F,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;SACF;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC;AAdD,6BAcC","sourcesContent":["/**\n * Provides a try guarded require call that will throw a more detailed error when\n * the ERR_REQUIRE_ESM error code is encountered.\n *\n * @param {string} path File path to require from.\n */\nexport default function tryRequire(path: string) {\n try {\n return require(path)\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n throw Error(\n `Cucumber expected a CommonJS module at '${path}' but found an ES module.\n Either change the file to CommonJS syntax or use the --import directive instead of --require.`,\n { cause: error }\n )\n } else {\n throw error\n }\n }\n}\n"]}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "10.0.0";
1
+ export declare const version = "10.1.0";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '10.0.0';
5
+ exports.version = '10.1.0';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '10.0.0'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '10.1.0'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "10.0.0",
11
+ "version": "10.1.0",
12
12
  "homepage": "https://github.com/cucumber/cucumber-js",
13
13
  "author": "Julien Biezemans <jb@jbpros.com>",
14
14
  "contributors": [
@@ -123,6 +123,7 @@
123
123
  "Michael Lloyd Morris (https://github.com/michael-lloyd-morris)",
124
124
  "Michael Zedeler <michael@zedeler.dk>",
125
125
  "Miika Hänninen <miika.hanninen@gmail.com>",
126
+ "Mona Ghassemi (https://github.com/BlueMona)",
126
127
  "nebehr <thorgeir@tut.by>",
127
128
  "Nico Jansen <jansennico@gmail.com>",
128
129
  "Niklas Närhinen <niklas@narhinen.net>",
@@ -204,18 +205,18 @@
204
205
  "node": "18 || >=20"
205
206
  },
206
207
  "enginesTested": {
207
- "node": "18 || 20"
208
+ "node": "18 || 20 || 21"
208
209
  },
209
210
  "dependencies": {
210
- "@cucumber/ci-environment": "9.2.0",
211
- "@cucumber/cucumber-expressions": "16.1.2",
212
- "@cucumber/gherkin": "26.2.0",
211
+ "@cucumber/ci-environment": "10.0.0",
212
+ "@cucumber/cucumber-expressions": "17.0.1",
213
+ "@cucumber/gherkin": "27.0.0",
213
214
  "@cucumber/gherkin-streams": "5.0.1",
214
- "@cucumber/gherkin-utils": "8.0.2",
215
- "@cucumber/html-formatter": "20.4.0",
215
+ "@cucumber/gherkin-utils": "8.0.5",
216
+ "@cucumber/html-formatter": "21.2.0",
216
217
  "@cucumber/message-streams": "4.0.1",
217
- "@cucumber/messages": "22.0.0",
218
- "@cucumber/tag-expressions": "5.0.1",
218
+ "@cucumber/messages": "24.0.1",
219
+ "@cucumber/tag-expressions": "6.0.0",
219
220
  "assertion-error-formatter": "^3.0.0",
220
221
  "capital-case": "^1.0.4",
221
222
  "chalk": "^4.1.2",
@@ -239,18 +240,18 @@
239
240
  "read-pkg-up": "^7.0.1",
240
241
  "resolve-pkg": "^2.0.0",
241
242
  "semver": "7.5.3",
242
- "string-argv": "^0.3.1",
243
+ "string-argv": "0.3.1",
243
244
  "strip-ansi": "6.0.1",
244
245
  "supports-color": "^8.1.1",
245
246
  "tmp": "^0.2.1",
247
+ "type-fest": "^4.8.3",
246
248
  "util-arity": "^1.1.0",
247
- "verror": "^1.10.0",
248
249
  "xmlbuilder": "^15.1.1",
249
250
  "yaml": "^2.2.2",
250
251
  "yup": "1.2.0"
251
252
  },
252
253
  "devDependencies": {
253
- "@cucumber/compatibility-kit": "^12.0.0",
254
+ "@cucumber/compatibility-kit": "14.1.0",
254
255
  "@cucumber/query": "12.0.1",
255
256
  "@microsoft/api-documenter": "7.19.27",
256
257
  "@microsoft/api-extractor": "7.33.7",
@@ -276,7 +277,6 @@
276
277
  "@types/sinonjs__fake-timers": "8.1.2",
277
278
  "@types/stream-buffers": "3.0.4",
278
279
  "@types/tmp": "0.2.3",
279
- "@types/verror": "1.10.6",
280
280
  "@typescript-eslint/eslint-plugin": "6.7.4",
281
281
  "@typescript-eslint/parser": "6.7.4",
282
282
  "chai": "4.3.7",
@@ -302,7 +302,6 @@
302
302
  "shx": "0.3.4",
303
303
  "sinon": "15.0.1",
304
304
  "sinon-chai": "3.7.0",
305
- "stream-buffers": "3.0.2",
306
305
  "stream-to-string": "1.2.0",
307
306
  "ts-node": "10.9.1",
308
307
  "tsd": "0.25.0",
@@ -1,8 +0,0 @@
1
- import { ILogger } from '../logger';
2
- import { ISourcesCoordinates, ISupportCodeCoordinates } from './types';
3
- export declare function resolvePaths(logger: ILogger, cwd: string, sources: Pick<ISourcesCoordinates, 'paths'>, support?: ISupportCodeCoordinates): Promise<{
4
- unexpandedFeaturePaths: string[];
5
- featurePaths: string[];
6
- requirePaths: string[];
7
- importPaths: string[];
8
- }>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/api/paths.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,+BAA2B;AAC3B,+CAAsB;AAIf,KAAK,UAAU,YAAY,CAChC,MAAe,EACf,GAAW,EACX,OAA2C,EAC3C,UAAmC;IACjC,cAAc,EAAE,EAAE;IAClB,YA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nC,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAClC;QACA,MAAM,YAAY,GAAG,wBAAwB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;QAChE,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAA;QAC1E,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,CAAA;KACzC;IACD,MAAM,YAAY,GAChB,sBAAsB,CAAC,MAAM,GAAG,CAAC;QAC/B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,CAAC;QACvD,CAAC,CAAC,EAAE,CAAA;IACR,MAAM,WAAW,GACf,qBAAqB,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,qBAAqB,EAAE,gBAAgB,CAAC;QACjE,CAAC,CAAC,EAAE,CAAA;IACR,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA;AACtC,CAAC","sourcesContent":["import path from 'node:path'\nimport { glob } from 'glob'\nimport fs from 'mz/fs'\nimport { ILogger } from '../logger'\nimport { ISourcesCoordinates, ISupportCodeCoordinates } from './types'\n\nexport async function resolvePaths(\n logger: ILogger,\n cwd: string,\n sources: Pick<ISourcesCoordinates, 'paths'>,\n support: ISupportCodeCoordinates = {\n requireModules: [],\n requirePaths: [],\n importPaths: [],\n }\n): Promise<{\n unexpandedFeaturePaths: string[]\n featurePaths: string[]\n requirePaths: string[]\n importPaths: string[]\n}> {\n const unexpandedFeaturePaths = await getUnexpandedFeaturePaths(\n cwd,\n sources.paths\n )\n const featurePaths: string[] = await expandFeaturePaths(\n cwd,\n unexpandedFeaturePaths\n )\n logger.debug('Found feature files based on configuration:', featurePaths)\n const { requirePaths, importPaths } = await deriveSupportPaths(\n cwd,\n featurePaths,\n support.requirePaths,\n support.importPaths\n )\n logger.debug(\n 'Found support files to load via `require` based on configuration:',\n requirePaths\n )\n logger.debug(\n 'Found support files to load via `import` based on configuration:',\n importPaths\n )\n return {\n unexpandedFeaturePaths,\n featurePaths,\n requirePaths,\n importPaths,\n }\n}\n\nasync function expandPaths(\n cwd: string,\n unexpandedPaths: string[],\n defaultExtension: string\n): Promise<string[]> {\n const expandedPaths = await Promise.all(\n unexpandedPaths.map(async (unexpandedPath) => {\n const matches = await glob(unexpandedPath, {\n absolute: true,\n windowsPathsNoEscape: true,\n cwd,\n })\n const expanded = await Promise.all(\n matches.map(async (match) => {\n if (path.extname(match) === '') {\n return glob(`${match}/**/*${defaultExtension}`, {\n windowsPathsNoEscape: true,\n })\n }\n return [match]\n })\n )\n return expanded.flat()\n })\n )\n const normalized = expandedPaths.flat().map((x) => path.normalize(x))\n normalized.sort()\n return [...new Set(normalized)]\n}\n\nasync function getUnexpandedFeaturePaths(\n cwd: string,\n args: string[]\n): Promise<string[]> {\n if (args.length > 0) {\n const nestedFeaturePaths = await Promise.all(\n args.map(async (arg) => {\n const filename = path.basename(arg)\n if (filename[0] === '@') {\n const filePath = path.join(cwd, arg)\n const content = await fs.readFile(filePath, 'utf8')\n return content.split('\\n').map((x) => x.trim())\n }\n return [arg]\n })\n )\n const featurePaths = nestedFeaturePaths.flat()\n if (featurePaths.length > 0) {\n return featurePaths.filter((x) => x !== '')\n }\n }\n return ['features/**/*.{feature,feature.md}']\n}\n\nfunction getFeatureDirectoryPaths(\n cwd: string,\n featurePaths: string[]\n): string[] {\n const featureDirs = featurePaths.map((featurePath) => {\n let featureDir = path.dirname(featurePath)\n let childDir: string\n let parentDir = featureDir\n while (childDir !== parentDir) {\n childDir = parentDir\n parentDir = path.dirname(childDir)\n if (path.basename(parentDir) === 'features') {\n featureDir = parentDir\n break\n }\n }\n return path.relative(cwd, featureDir)\n })\n return [...new Set(featureDirs)]\n}\n\nasync function expandFeaturePaths(\n cwd: string,\n featurePaths: string[]\n): Promise<string[]> {\n featurePaths = featurePaths.map((p) => p.replace(/(:\\d+)*$/g, '')) // Strip line numbers\n return await expandPaths(cwd, featurePaths, '.feature')\n}\n\nasync function deriveSupportPaths(\n cwd: string,\n featurePaths: string[],\n unexpandedRequirePaths: string[],\n unexpandedImportPaths: string[]\n): Promise<{\n requirePaths: string[]\n importPaths: string[]\n}> {\n if (\n unexpandedRequirePaths.length === 0 &&\n unexpandedImportPaths.length === 0\n ) {\n const defaultPaths = getFeatureDirectoryPaths(cwd, featurePaths)\n const importPaths = await expandPaths(cwd, defaultPaths, '.@(js|cjs|mjs)')\n return { requirePaths: [], importPaths }\n }\n const requirePaths =\n unexpandedRequirePaths.length > 0\n ? await expandPaths(cwd, unexpandedRequirePaths, '.js')\n : []\n const importPaths =\n unexpandedImportPaths.length > 0\n ? await expandPaths(cwd, unexpandedImportPaths, '.@(js|cjs|mjs)')\n : []\n return { requirePaths, importPaths }\n}\n"]}