@lynxwall/cucumber-tsflow 7.2.0 → 7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +59 -35
  2. package/lib/api/load-configuration.js +60 -16
  3. package/lib/api/load-configuration.js.map +1 -1
  4. package/lib/bindings/binding-context.d.ts +40 -4
  5. package/lib/bindings/binding-context.js +50 -6
  6. package/lib/bindings/binding-context.js.map +1 -1
  7. package/lib/bindings/binding-decorator.js +32 -9
  8. package/lib/bindings/binding-decorator.js.map +1 -1
  9. package/lib/bindings/binding-registry.js +10 -0
  10. package/lib/bindings/binding-registry.js.map +1 -1
  11. package/lib/bindings/hook-decorators.js +4 -3
  12. package/lib/bindings/hook-decorators.js.map +1 -1
  13. package/lib/bindings/step-decorators.js +12 -9
  14. package/lib/bindings/step-decorators.js.map +1 -1
  15. package/lib/cli/argv-parser.js +1 -2
  16. package/lib/cli/argv-parser.js.map +1 -1
  17. package/lib/runtime/parallel/worker.js +1 -1
  18. package/lib/runtime/parallel/worker.js.map +1 -1
  19. package/lib/runtime/test-case-runner.d.ts +2 -1
  20. package/lib/runtime/test-case-runner.js +8 -5
  21. package/lib/runtime/test-case-runner.js.map +1 -1
  22. package/lib/transpilers/esbuild-transpiler.d.ts +1 -1
  23. package/lib/transpilers/esbuild-transpiler.js.map +1 -1
  24. package/lib/transpilers/esbuild.js.map +1 -1
  25. package/lib/transpilers/esm/esbuild-transpiler-cjs.js +2174 -0
  26. package/lib/transpilers/esm/esbuild-transpiler.mjs +19 -0
  27. package/lib/transpilers/esm/esbuild.mjs +141 -0
  28. package/lib/transpilers/esm/esmbuild-transpiler.d.ts +4 -0
  29. package/lib/transpilers/esm/esmbuild-transpiler.js +19 -0
  30. package/lib/transpilers/esm/esmbuild-transpiler.js.map +1 -0
  31. package/lib/transpilers/esm/esmbuild.d.ts +12 -0
  32. package/lib/transpilers/esm/esmbuild.js +72 -0
  33. package/lib/transpilers/esm/esmbuild.js.map +1 -0
  34. package/lib/transpilers/esm/esmnode.d.ts +1 -0
  35. package/lib/transpilers/esm/esmnode.js +8 -0
  36. package/lib/transpilers/esm/esmnode.js.map +1 -0
  37. package/lib/transpilers/esm/esmvue.d.ts +1 -0
  38. package/lib/transpilers/esm/esmvue.js +29 -0
  39. package/lib/transpilers/esm/esmvue.js.map +1 -0
  40. package/lib/transpilers/esm/esnode-loader.mjs +9 -0
  41. package/lib/transpilers/esm/esvue-loader.mjs +9 -0
  42. package/lib/transpilers/esm/loader-utils.mjs +356 -0
  43. package/lib/transpilers/esm/tsnode-esm.d.ts +1 -0
  44. package/lib/transpilers/esm/tsnode-esm.js +25 -0
  45. package/lib/transpilers/esm/tsnode-esm.js.map +1 -0
  46. package/lib/transpilers/esm/tsnode-exp-esm.d.ts +1 -0
  47. package/lib/transpilers/esm/tsnode-exp-esm.js +19 -0
  48. package/lib/transpilers/esm/tsnode-exp-esm.js.map +1 -0
  49. package/lib/transpilers/esm/tsnode-loader.mjs +107 -0
  50. package/lib/transpilers/esm/tsnode-service.mjs +40 -0
  51. package/lib/transpilers/esm/tsvue-esm.d.ts +1 -0
  52. package/lib/transpilers/esm/tsvue-esm.js +40 -0
  53. package/lib/transpilers/esm/tsvue-esm.js.map +1 -0
  54. package/lib/transpilers/esm/tsvue-exp-esm.d.ts +1 -0
  55. package/lib/transpilers/esm/tsvue-exp-esm.js +40 -0
  56. package/lib/transpilers/esm/tsvue-exp-esm.js.map +1 -0
  57. package/lib/transpilers/esm/vue-jsdom-setup.mjs +19 -0
  58. package/lib/transpilers/esm/vue-loader.mjs +113 -0
  59. package/lib/transpilers/esm/vue-sfc-compiler.mjs +216 -0
  60. package/lib/transpilers/esnode.js +1 -1
  61. package/lib/transpilers/esnode.js.map +1 -1
  62. package/lib/transpilers/esvue.js +1 -1
  63. package/lib/transpilers/esvue.js.map +1 -1
  64. package/lib/transpilers/tsnode-exp.js +1 -1
  65. package/lib/transpilers/tsnode-exp.js.map +1 -1
  66. package/lib/transpilers/tsnode.js +1 -1
  67. package/lib/transpilers/tsnode.js.map +1 -1
  68. package/lib/transpilers/tsvue-exp.js +1 -1
  69. package/lib/transpilers/tsvue-exp.js.map +1 -1
  70. package/lib/transpilers/tsvue.js +2 -2
  71. package/lib/transpilers/tsvue.js.map +1 -1
  72. package/lib/transpilers/vue-sfc/index.js.map +1 -1
  73. package/lib/tsconfig.node.tsbuildinfo +1 -1
  74. package/lib/version.d.ts +1 -1
  75. package/lib/version.js +1 -1
  76. package/lib/version.js.map +1 -1
  77. package/package.json +27 -17
@@ -1 +1 @@
1
- {"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../../src/bindings/binding-decorator.ts"],"names":[],"mappings":";;;;;AAyCA,0BAwCC;AAjFD,iDAW4B;AAC5B,uDAAwE;AACxE,yDAAkE;AAClE,iDAA+D;AAE/D,iDAAyD;AACzD,4DAA2B;AAM3B;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAiC,CAAC;AAE1E;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,oBAAoC;IAC3D,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAmC,EAAE,EAAE;YACjD,MAAM,eAAe,GAAG,kCAAe,CAAC,QAAQ,CAAC;YACjD,eAAe,CAAC,4BAA4B,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACrF,gBAAgB,EAAE,CAAC;YAEnB,qGAAqG;YACrG,gEAAgE;YAChE,4FAA4F;YAC5F,MAAM,WAAW,GAAkB,IAAA,oCAAkB,GAAE,CAAC;YACxD,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBACjC,uBAAuB;gBACvB,eAAe,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;gBAEjD,+CAA+C;gBAC/C,cAAc,CAAC,WAAW,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC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Y,CAAC,CAAC;YAClC,MAAM;QACP,CAAC;QACD,KAAK,+BAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChC,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACvF,IAAA,mBAAQ,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;YACtC,MAAM;QACP,CAAC;QACD,KAAK,+BAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7B,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACnG,IAAA,gBAAK,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAC7B,MAAM;QACP,CAAC;QACD,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YACjC,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACnG,IAAA,oBAAS,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACjC,MAAM;QACP,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import {\r\n\tAfter,\r\n\tAfterStep,\r\n\tAfterAll,\r\n\tBefore,\r\n\tBeforeStep,\r\n\tBeforeAll,\r\n\tGiven,\r\n\tThen,\r\n\tWhen,\r\n\tWorld\r\n} from '@cucumber/cucumber';\r\nimport { getStepBindings, getStepBindingsExp } from './binding-context';\r\nimport { BindingRegistry, DEFAULT_TAG } from './binding-registry';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern } from './types';\r\nimport { defineParameterType } from '@cucumber/cucumber';\r\nimport _ from 'underscore';\r\n\r\ninterface WritableWorld extends World {\r\n\t[key: string]: any;\r\n}\r\n\r\n/**\r\n * A set of step patterns that have been registered with Cucumber.\r\n *\r\n * In order to support scoped (or tagged) step definitions, we must ensure that any step binding is\r\n * only registered with Cucumber once. The binding function for that step pattern then becomes\r\n * responsible for looking up and execuing the step binding based on the context that is in scope at\r\n * the point of invocation.\r\n */\r\nconst stepPatternRegistrations = new Map<StepPattern, StepBindingFlags>();\r\n\r\n/**\r\n * A class decorator that marks the associated class as a CucumberJS binding.\r\n *\r\n * @param requiredContextTypes An optional array of Types that will be created and passed into the created\r\n * object for each scenario.\r\n *\r\n * An instance of the decorated class will be created for each scenario.\r\n */\r\nexport function binding(requiredContextTypes?: ContextType[]): any {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: { new (...args: any[]): T }) => {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\t\t\tdefineParameters();\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindingsExp();\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// register the binding\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// add the step binding to the binding registry\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\t\t};\r\n\t} else {\r\n\t\treturn function classDecorator(target: Function, context: ClassDecoratorContext) {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\t\t\tdefineParameters();\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindings(context);\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// Set the class prototype and then register the binding with the prototype\r\n\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// add the step binding to the binding registry\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\t\t\treturn target;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Called only once to register new parameters. This has to be\r\n * executed here during binding initialization for cucumber to\r\n * to use it when matching expressions. Attempting to add it\r\n * before the test run doesn't work\r\n */\r\nconst defineParameters = _.once(() => {\r\n\tdefineParameterType({\r\n\t\tname: 'boolean',\r\n\t\tregexp: /true|false/,\r\n\t\ttransformer: s => (s === 'true' ? true : false)\r\n\t});\r\n});\r\n\r\n/**\r\n * Common helper used to add StepBindings to the binding registry\r\n * @param stepBinding\r\n * @returns\r\n */\r\nfunction addStepBinding(stepBinding: StepBinding): void {\r\n\tif (stepBinding.bindingType & StepBindingFlags.StepDefinitions) {\r\n\t\tlet stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());\r\n\t\tif (stepBindingFlags === undefined) {\r\n\t\t\tstepBindingFlags = StepBindingFlags.none;\r\n\t\t}\r\n\t\tif (stepBindingFlags & stepBinding.bindingType) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbindStepDefinition(stepBinding);\r\n\t\tstepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.Hooks) {\r\n\t\tbindHook(stepBinding);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a step definition to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'given', 'when', or 'then' step definition.\r\n */\r\nfunction bindStepDefinition(stepBinding: StepBinding): void {\r\n\tconst stepFunction = function (this: WritableWorld): any {\r\n\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\r\n\t\tconst scenarioContext = global.messageCollector.getStepScenarioContext(stepBinding);\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst matchingStepBindings = bindingRegistry.getStepBindings(\r\n\t\t\t\tstepBinding.stepPattern.toString(),\r\n\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t);\r\n\r\n\t\t\tif (matchingStepBindings.length > 1) {\r\n\t\t\t\tlet message = `Ambiguous step definitions for '${matchingStepBindings[0].stepPattern}':\\n`;\r\n\r\n\t\t\t\tmatchingStepBindings.forEach(matchingStepBinding => {\r\n\t\t\t\t\tmessage =\r\n\t\t\t\t\t\tmessage +\r\n\t\t\t\t\t\t`\\t\\t${String(matchingStepBinding.classPropertyKey)} (${matchingStepBinding.callsite.toString()})\\n`;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthrow new Error(message);\r\n\t\t\t} else if (matchingStepBindings.length === 0) {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Cannot find matched step definition for ${stepBinding.stepPattern.toString()} with tag ${\r\n\t\t\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t\t\t} in binding registry`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst contextTypes = bindingRegistry.getContextTypesForClass(matchingStepBindings[0].classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(\r\n\t\t\t\tmatchingStepBindings[0].classPrototype,\r\n\t\t\t\tcontextTypes,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t\tbindingObject._worldObj = this;\r\n\r\n\t\t\treturn (bindingObject[matchingStepBindings[0].classPropertyKey] as Function).apply(\r\n\t\t\t\tbindingObject,\r\n\t\t\t\targuments as any\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for a Step!');\r\n\t\t}\r\n\t};\r\n\r\n\tObject.defineProperty(stepFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\t// initialize options used on all step bindings\r\n\tconst options = {\r\n\t\tcucumberKey: stepBinding.cucumberKey,\r\n\t\ttimeout: stepBinding.timeout,\r\n\t\twrapperOptions: stepBinding.wrapperOption\r\n\t};\r\n\t// call appropriate step\r\n\tif (stepBinding.bindingType & StepBindingFlags.given) {\r\n\t\tGiven(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.when) {\r\n\t\tWhen(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.then) {\r\n\t\tThen(stepBinding.stepPattern, options, stepFunction);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a hook to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'before', or 'after', step definition.\r\n */\r\nfunction bindHook(stepBinding: StepBinding): void {\r\n\t// beforeAll and afterAll are called before and after all tests.\r\n\t// these can be class instance or static functions\r\n\tconst globalHookFunction = function (this: any): any {\r\n\t\t// if the function is static we need to add it to the associated class first\r\n\t\tif (stepBinding.stepIsStatic && !stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\tstepBinding.classPrototype[stepBinding.classPropertyKey] = stepBinding.stepFunction;\r\n\t\t}\r\n\t\treturn stepBinding.classPrototype[stepBinding.classPropertyKey].apply() as () => void;\r\n\t};\r\n\t// Main binding for all other steps\r\n\tconst hookFunction = function (this: any, arg: any): any {\r\n\t\tconst scenarioContext = global.messageCollector.getHookScenarioContext(arg);\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst contextTypes = BindingRegistry.instance.getContextTypesForClass(stepBinding.classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(stepBinding.classPrototype, contextTypes, this);\r\n\t\t\tbindingObject._worldObj = this;\r\n\t\t\treturn (bindingObject[stepBinding.classPropertyKey] as Function).apply(bindingObject, arguments as any);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for Hook!');\r\n\t\t}\r\n\t};\r\n\t// length values need to be added to our binding functions.\r\n\t// These are used in cucumber to determine if the function is\r\n\t// a callback or promise.\r\n\tObject.defineProperty(globalHookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\tObject.defineProperty(hookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\tconst tags = stepBinding.tags === DEFAULT_TAG ? undefined : stepBinding.tags;\r\n\r\n\t// This binds the appropriate function above to the associated\r\n\t// cucumber step functions.\r\n\tswitch (stepBinding.bindingType) {\r\n\t\tcase StepBindingFlags.beforeAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tBeforeAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.before: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBefore(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.beforeStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBeforeStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tAfterAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.after: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfter(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfterStep(options, hook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AAC;YACjC,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACnG,IAAA,oBAAS,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACjC,MAAM;QACP,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import {\r\n\tAfter,\r\n\tAfterStep,\r\n\tAfterAll,\r\n\tBefore,\r\n\tBeforeStep,\r\n\tBeforeAll,\r\n\tGiven,\r\n\tThen,\r\n\tWhen,\r\n\tWorld\r\n} from '@cucumber/cucumber';\r\nimport { getStepBindings, getStepBindingsExp, getCollectedBindings } from './binding-context';\r\nimport { BindingRegistry, DEFAULT_TAG } from './binding-registry';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern } from './types';\r\nimport { defineParameterType } from '@cucumber/cucumber';\r\nimport _ from 'underscore';\r\n\r\ninterface WritableWorld extends World {\r\n\t[key: string]: any;\r\n}\r\n\r\n/**\r\n * A set of step patterns that have been registered with Cucumber.\r\n *\r\n * In order to support scoped (or tagged) step definitions, we must ensure that any step binding is\r\n * only registered with Cucumber once. The binding function for that step pattern then becomes\r\n * responsible for looking up and execuing the step binding based on the context that is in scope at\r\n * the point of invocation.\r\n */\r\nconst stepPatternRegistrations = new Map<StepPattern, StepBindingFlags>();\r\n\r\n/**\r\n * A class decorator that marks the associated class as a CucumberJS binding.\r\n *\r\n * @param requiredContextTypes An optional array of Types that will be created and passed into the created\r\n * object for each scenario.\r\n *\r\n * An instance of the decorated class will be created for each scenario.\r\n */\r\nexport function binding(requiredContextTypes?: ContextType[]): any {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: { new (...args: any[]): T }) => {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\t\t\tdefineParameters();\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindingsExp();\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// For static methods, we need to set the classPrototype to the class itself, not the prototype\r\n\t\t\t\tif (stepBinding.stepIsStatic) {\r\n\t\t\t\t\tstepBinding.classPrototype = target;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// Register with cucumber\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\t\t};\r\n\t} else {\r\n\t\treturn function classDecorator(target: Function, context: ClassDecoratorContext) {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\t\t\tdefineParameters();\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindings(context);\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// Set the class prototype and then register the binding with the prototype\r\n\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// add the step binding to the binding registry\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\r\n\t\t\t// Process pending step bindings after class is decorated\r\n\t\t\tcontext.addInitializer(function () {\r\n\t\t\t\t// Get all the collected bindings\r\n\t\t\t\tconst allBindings = getCollectedBindings();\r\n\r\n\t\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t\t// Set the class prototype and register\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t\t// Register with cucumber - call the local addStepBinding function\r\n\t\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t\treturn target;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Called only once to register new parameters. This has to be\r\n * executed here during binding initialization for cucumber to\r\n * to use it when matching expressions. Attempting to add it\r\n * before the test run doesn't work\r\n */\r\nconst defineParameters = _.once(() => {\r\n\tdefineParameterType({\r\n\t\tname: 'boolean',\r\n\t\tregexp: /true|false/,\r\n\t\ttransformer: s => (s === 'true' ? true : false)\r\n\t});\r\n});\r\n\r\n/**\r\n * Common helper used to add StepBindings to the binding registry\r\n * @param stepBinding\r\n * @returns\r\n */\r\nfunction addStepBinding(stepBinding: StepBinding): void {\r\n\tif (stepBinding.bindingType & StepBindingFlags.StepDefinitions) {\r\n\t\tlet stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());\r\n\t\tif (stepBindingFlags === undefined) {\r\n\t\t\tstepBindingFlags = StepBindingFlags.none;\r\n\t\t}\r\n\t\tif (stepBindingFlags & stepBinding.bindingType) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbindStepDefinition(stepBinding);\r\n\t\tstepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.Hooks) {\r\n\t\tbindHook(stepBinding);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a step definition to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'given', 'when', or 'then' step definition.\r\n */\r\nfunction bindStepDefinition(stepBinding: StepBinding): void {\r\n\tconst stepFunction = function (this: WritableWorld): any {\r\n\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\r\n\t\tconst scenarioContext = global.messageCollector.getStepScenarioContext(stepBinding);\r\n\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst matchingStepBindings = bindingRegistry.getStepBindings(\r\n\t\t\t\tstepBinding.stepPattern.toString(),\r\n\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t);\r\n\r\n\t\t\tif (matchingStepBindings.length > 1) {\r\n\t\t\t\tlet message = `Ambiguous step definitions for '${matchingStepBindings[0].stepPattern}':\\n`;\r\n\r\n\t\t\t\tmatchingStepBindings.forEach(matchingStepBinding => {\r\n\t\t\t\t\tmessage =\r\n\t\t\t\t\t\tmessage +\r\n\t\t\t\t\t\t`\\t\\t${String(matchingStepBinding.classPropertyKey)} (${matchingStepBinding.callsite.toString()})\\n`;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthrow new Error(message);\r\n\t\t\t} else if (matchingStepBindings.length === 0) {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Cannot find matched step definition for ${stepBinding.stepPattern.toString()} with tag ${\r\n\t\t\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t\t\t} in binding registry`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst contextTypes = bindingRegistry.getContextTypesForClass(matchingStepBindings[0].classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(\r\n\t\t\t\tmatchingStepBindings[0].classPrototype,\r\n\t\t\t\tcontextTypes,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t\tbindingObject._worldObj = this;\r\n\r\n\t\t\treturn (bindingObject[matchingStepBindings[0].classPropertyKey] as Function).apply(\r\n\t\t\t\tbindingObject,\r\n\t\t\t\targuments as any\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for a Step!');\r\n\t\t}\r\n\t};\r\n\r\n\tObject.defineProperty(stepFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\t// initialize options used on all step bindings\r\n\tconst options = {\r\n\t\tcucumberKey: stepBinding.cucumberKey,\r\n\t\ttimeout: stepBinding.timeout,\r\n\t\twrapperOptions: stepBinding.wrapperOption\r\n\t};\r\n\t// call appropriate step\r\n\tif (stepBinding.bindingType & StepBindingFlags.given) {\r\n\t\tGiven(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.when) {\r\n\t\tWhen(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.then) {\r\n\t\tThen(stepBinding.stepPattern, options, stepFunction);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a hook to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'before', or 'after', step definition.\r\n */\r\nfunction bindHook(stepBinding: StepBinding): void {\r\n\tconst globalHookFunction = function (this: any): any {\r\n\t\t// Check if it's a static method\r\n\t\tif (stepBinding.stepIsStatic || !stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\tconst constructor = stepBinding.classPrototype.constructor;\r\n\r\n\t\t\tif (constructor && constructor[stepBinding.classPropertyKey]) {\r\n\t\t\t\treturn constructor[stepBinding.classPropertyKey].apply(constructor);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// For non-static methods\r\n\t\tif (stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\treturn stepBinding.classPrototype[stepBinding.classPropertyKey].apply(stepBinding.classPrototype);\r\n\t\t}\r\n\r\n\t\tthrow new Error(\r\n\t\t\t`Method ${String(stepBinding.classPropertyKey)} not found on class ${stepBinding.classPrototype?.constructor?.name}`\r\n\t\t);\r\n\t};\r\n\t// Main binding for all other hooks (before, after, beforeStep, afterStep)\r\n\tconst hookFunction = function (this: any, arg: any): any {\r\n\t\tconst scenarioContext = global.messageCollector.getHookScenarioContext(arg);\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst contextTypes = BindingRegistry.instance.getContextTypesForClass(stepBinding.classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(stepBinding.classPrototype, contextTypes, this);\r\n\t\t\tbindingObject._worldObj = this;\r\n\t\t\treturn (bindingObject[stepBinding.classPropertyKey] as Function).apply(bindingObject, arguments as any);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for Hook!');\r\n\t\t}\r\n\t};\r\n\t// length values need to be added to our binding functions.\r\n\t// These are used in cucumber to determine if the function is\r\n\t// a callback or promise.\r\n\tObject.defineProperty(globalHookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\tObject.defineProperty(hookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\tconst tags = stepBinding.tags === DEFAULT_TAG ? undefined : stepBinding.tags;\r\n\r\n\t// This binds the appropriate function above to the associated\r\n\t// cucumber step functions.\r\n\tswitch (stepBinding.bindingType) {\r\n\t\tcase StepBindingFlags.beforeAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tBeforeAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.before: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBefore(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.beforeStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBeforeStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tAfterAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.after: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfter(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfterStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]}
@@ -113,6 +113,16 @@ class BindingRegistry {
113
113
  targetBinding.stepBindings.push(stepBinding);
114
114
  }
115
115
  function isSameStepBinding(a, b) {
116
+ // For hooks, we need to check the binding type and method name too
117
+ if (a.bindingType & step_binding_1.StepBindingFlags.Hooks) {
118
+ return (a.callsite.filename === b.callsite.filename &&
119
+ a.callsite.lineNumber === b.callsite.lineNumber &&
120
+ String(a.tags) === String(b.tags) &&
121
+ String(a.stepPattern) === String(b.stepPattern) &&
122
+ a.bindingType === b.bindingType &&
123
+ a.classPropertyKey === b.classPropertyKey);
124
+ }
125
+ // For step definitions, the existing check is fine
116
126
  return (a.callsite.filename === b.callsite.filename &&
117
127
  a.callsite.lineNumber === b.callsite.lineNumber &&
118
128
  String(a.tags) === String(b.tags) &&
@@ -1 +1 @@
1
- {"version":3,"file":"binding-registry.js","sourceRoot":"","sources":["../../src/bindings/binding-registry.ts"],"names":[],"mappings":";;;;;;AACA,4DAA2B;AAC3B,iDAA+D;AAE/D,6DAAqC;AAiBrC;;GAEG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACU,QAAA,WAAW,GAAG,GAAG,CAAC;AAE/B;;GAEG;AACH,MAAa,eAAe;IACnB,aAAa,GAAG,IAAI,GAAG,EAA4C,CAAC;IACpE,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEtD;;;;OAIG;IACI,MAAM,KAAK,QAAQ;QACzB,MAAM,yBAAyB,GAAG,mCAAmC,CAAC;QAEtE,MAAM,QAAQ,GAAI,MAAc,C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MAAM;gBACR,CAAC;gBACD,IAAI,kBAAkB,EAAE,CAAC;oBACxB,kBAAkB,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;oBAC1D,kBAAkB,CAAC,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;IAEF;;;;;;;OAOG;IACK,yBAAyB,CAAC,IAAe,EAAE,MAAmC;QACrF,MAAM,oBAAoB,GAAgC,oBAAC,CAAC,OAAO,CAAC,oBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEzG,OAAO,oBAAC,CAAC,MAAM,CAAC,oBAAoB,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,KAAK,SAAS,CAAkB,CAAC;IAClG,CAAC;CACD;AA7QD,0CA6QC","sourcesContent":["import { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport _ from 'underscore';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern, TagName } from './types';\r\nimport logger from '../utils/logger';\r\n\r\n/**\r\n * Describes the binding metadata that is associated with a binding class.\r\n */\r\ninterface ClassBinding {\r\n\t/**\r\n\t * A reference to the step bindings that are associated with the binding class.\r\n\t */\r\n\tstepBindings: StepBinding[];\r\n\r\n\t/**\r\n\t * The context types that are to be injected into the binding class during execution.\r\n\t */\r\n\tcontextTypes: ContextType[];\r\n}\r\n\r\n/**\r\n * Represents the default step pattern.\r\n */\r\nexport const DEFAULT_STEP_PATTERN = '/.*/';\r\n\r\n/**\r\n * Represents the default tag.\r\n */\r\nexport const DEFAULT_TAG = '*';\r\n\r\n/**\r\n * A metadata registry that captures information about bindings and their bound step bindings.\r\n */\r\nexport class BindingRegistry {\r\n\tprivate _stepBindings = new Map<StepPattern, Map<TagName, StepBinding[]>>();\r\n\tprivate _classBindings = new Map<any, ClassBinding>();\r\n\r\n\t/**\r\n\t * Gets the binding registry singleton.\r\n\t *\r\n\t * @returns A [[BindingRegistry]].\r\n\t */\r\n\tpublic static get instance(): BindingRegistry {\r\n\t\tconst BINDING_REGISTRY_SLOTNAME = '__CUCUMBER_TSFLOW_BINDINGREGISTRY';\r\n\r\n\t\tconst registry = (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\r\n\t\tif (!registry) {\r\n\t\t\t(global as any)[BINDING_REGISTRY_SLOTNAME] = new BindingRegistry();\r\n\t\t}\r\n\r\n\t\treturn registry || (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry with information about the context types required by a\r\n\t * binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t * @param contextTypes An array of [[ContextType]] that define the types of objects that\r\n\t * should be injected into the binding class during a scenario execution.\r\n\t */\r\n\tpublic registerContextTypesForClass(classPrototype: any, contextTypes?: ContextType[]): void {\r\n\t\tif (!contextTypes) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tlet targetDecorations = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetDecorations) {\r\n\t\t\ttargetDecorations = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(classPrototype, targetDecorations);\r\n\t\t}\r\n\r\n\t\ttargetDecorations.contextTypes = contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the context types that have been registered for a given binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[ContextType]] that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getContextTypesForClass(classPrototype: any): ContextType[] {\r\n\t\tconst targetBinding = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry indexes with a step binding.\r\n\t *\r\n\t * @param stepBinding The step binding that is to be registered with the binding registry.\r\n\t */\r\n\tpublic registerStepBinding(stepBinding: StepBinding): void {\r\n\t\tif (!stepBinding.tags) {\r\n\t\t\tstepBinding.tags = DEFAULT_TAG;\r\n\t\t}\r\n\r\n\t\tif (stepBinding.tags !== DEFAULT_TAG && !stepBinding.tags.startsWith('@')) {\r\n\t\t\t// tslint:disable-next-line:no-console\r\n\t\t\tlogger.debug('tag should start with @; tsflow has stopped to automatically prepend @ for you.');\r\n\t\t}\r\n\r\n\t\tconst stepPattern: StepPattern = stepBinding.stepPattern\r\n\t\t\t? stepBinding.stepPattern.toString()\r\n\t\t\t: DEFAULT_STEP_PATTERN;\r\n\r\n\t\tlet tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\ttagMap = new Map<TagName, StepBinding[]>();\r\n\r\n\t\t\tthis._stepBindings.set(stepPattern, tagMap);\r\n\t\t}\r\n\r\n\t\tlet stepBindings = tagMap.get(stepBinding.tags);\r\n\r\n\t\tif (!stepBindings) {\r\n\t\t\tstepBindings = [];\r\n\r\n\t\t\ttagMap.set(stepBinding.tags, stepBindings);\r\n\t\t}\r\n\r\n\t\tif (!stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\tstepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\t// Index the step binding for the target\r\n\r\n\t\tlet targetBinding = this._classBindings.get(stepBinding.classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\ttargetBinding = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(stepBinding.classPrototype, targetBinding);\r\n\t\t}\r\n\r\n\t\tif (!targetBinding.stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\ttargetBinding.stepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\tfunction isSameStepBinding(a: StepBinding, b: StepBinding) {\r\n\t\t\treturn (\r\n\t\t\t\ta.callsite.filename === b.callsite.filename &&\r\n\t\t\t\ta.callsite.lineNumber === b.callsite.lineNumber &&\r\n\t\t\t\tString(a.tags) === String(b.tags) &&\r\n\t\t\t\tString(a.stepPattern) === String(b.stepPattern)\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings that have been registered for a given binding class.\r\n\t *\r\n\t * @param targetPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[StepBinding]] objects that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getStepBindingsForTarget(targetPrototype: any): StepBinding[] {\r\n\t\tconst targetBinding = this._classBindings.get(targetPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.stepBindings;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings for a given step pattern and collection of tag names.\r\n\t *\r\n\t * @param stepPattern The step pattern to search.\r\n\t * @param tags An array of [[TagName]] to search.\r\n\t *\r\n\t * @returns An array of [[StepBinding]] that map to the given step pattern and set of tag names.\r\n\t */\r\n\tpublic getStepBindings(stepPattern: StepPattern, tags: TagName[]): StepBinding[] {\r\n\t\tconst tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tconst matchingStepBindings = this.mapTagNamesToStepBindings(tags, tagMap);\r\n\r\n\t\tif (matchingStepBindings.length > 0) {\r\n\t\t\treturn matchingStepBindings;\r\n\t\t}\r\n\r\n\t\treturn this.mapTagNamesToStepBindings(['*'], tagMap);\r\n\t}\r\n\r\n\tpublic getStepBindingByCucumberKey(cucumberKey: string): StepBinding | undefined {\r\n\t\tlet result: StepBinding | undefined = undefined;\r\n\t\tfor (const [_, binding] of this._classBindings) {\r\n\t\t\tfor (const stepBinding of binding.stepBindings) {\r\n\t\t\t\tif (stepBinding.cucumberKey === cucumberKey) {\r\n\t\t\t\t\tresult = stepBinding;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (result) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the SupportCodeLibrary from Cucumber with\r\n\t * callsite information from tsflow bindings\r\n\t * @param library\r\n\t * @returns\r\n\t */\r\n\tpublic updateSupportCodeLibrary = (library: SupportCodeLibrary): SupportCodeLibrary => {\r\n\t\tthis._classBindings.forEach(binding => {\r\n\t\t\tbinding.stepBindings.forEach(stepBinding => {\r\n\t\t\t\tlet cucumberDefinition: any | undefined = undefined;\r\n\t\t\t\tswitch (stepBinding.bindingType) {\r\n\t\t\t\t\tcase StepBindingFlags.beforeAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.before:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.beforeStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.given:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.when:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.then:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.after:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tif (cucumberDefinition) {\r\n\t\t\t\t\tcucumberDefinition.line = stepBinding.callsite.lineNumber;\r\n\t\t\t\t\tcucumberDefinition.uri = stepBinding.callsite.filename;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t\treturn library;\r\n\t};\r\n\r\n\t/**\r\n\t * Maps an array of tag names to an array of associated step bindings.\r\n\t *\r\n\t * @param tags An array of [[TagName]].\r\n\t * @param tagMap The map of [[TagName]] -> [[StepBinding]] to use when mapping.\r\n\t *\r\n\t * @returns An array of [[StepBinding]].\r\n\t */\r\n\tprivate mapTagNamesToStepBindings(tags: TagName[], tagMap: Map<TagName, StepBinding[]>): StepBinding[] {\r\n\t\tconst matchingStepBindings: (StepBinding | undefined)[] = _.flatten(_.map(tags, tag => tagMap.get(tag)));\r\n\r\n\t\treturn _.reject(matchingStepBindings, stepBinding => stepBinding === undefined) as StepBinding[];\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"binding-registry.js","sourceRoot":"","sources":["../../src/bindings/binding-registry.ts"],"names":[],"mappings":";;;;;;AACA,4DAA2B;AAC3B,iDAA+D;AAE/D,6DAAqC;AAiBrC;;GAEG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;GAEG;AACU,QAAA,WAAW,GAAG,GAAG,CAAC;AAE/B;;GAEG;AACH,MAAa,eAAe;IACnB,aAAa,GAAG,IAAI,GAAG,EAA4C,CAAC;IACpE,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEtD;;;;OAIG;IACI,MAAM,KAAK,QAAQ;QACzB,MAAM,yBAAyB,GAAG,mCAAmC,CAAC;QAEtE,MAAM,QAAQ,GAAI,MAAc,CAAC,yBAAyB,CAAC,CAAC;QAE5D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAc,CAAC,yBAAyB,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC;QACpE,CAAC;QAED,OAAO,QAAQ,IAAK,MAAc,CAAC,yBAAyB,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACI,4BAA4B,CAAC,cAAmB,EAAE,YAA4B;QACpF,IAAI,CAAC,YAAY,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QAED,IAAI,i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AAC,WAAW,CAC/D,CAAC;wBACF,MAAM;oBACP,KAAK,+BAAgB,CAAC,QAAQ;wBAC7B,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAC5D,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC,OAAe,CAAC,WAAW,KAAK,WAAW,CAAC,WAAW,CAC/D,CAAC;wBACF,MAAM;gBACR,CAAC;gBACD,IAAI,kBAAkB,EAAE,CAAC;oBACxB,kBAAkB,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;oBAC1D,kBAAkB,CAAC,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACxD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;IAEF;;;;;;;OAOG;IACK,yBAAyB,CAAC,IAAe,EAAE,MAAmC;QACrF,MAAM,oBAAoB,GAAgC,oBAAC,CAAC,OAAO,CAAC,oBAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEzG,OAAO,oBAAC,CAAC,MAAM,CAAC,oBAAoB,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,KAAK,SAAS,CAAkB,CAAC;IAClG,CAAC;CACD;AAxRD,0CAwRC","sourcesContent":["import { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport _ from 'underscore';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern, TagName } from './types';\r\nimport logger from '../utils/logger';\r\n\r\n/**\r\n * Describes the binding metadata that is associated with a binding class.\r\n */\r\ninterface ClassBinding {\r\n\t/**\r\n\t * A reference to the step bindings that are associated with the binding class.\r\n\t */\r\n\tstepBindings: StepBinding[];\r\n\r\n\t/**\r\n\t * The context types that are to be injected into the binding class during execution.\r\n\t */\r\n\tcontextTypes: ContextType[];\r\n}\r\n\r\n/**\r\n * Represents the default step pattern.\r\n */\r\nexport const DEFAULT_STEP_PATTERN = '/.*/';\r\n\r\n/**\r\n * Represents the default tag.\r\n */\r\nexport const DEFAULT_TAG = '*';\r\n\r\n/**\r\n * A metadata registry that captures information about bindings and their bound step bindings.\r\n */\r\nexport class BindingRegistry {\r\n\tprivate _stepBindings = new Map<StepPattern, Map<TagName, StepBinding[]>>();\r\n\tprivate _classBindings = new Map<any, ClassBinding>();\r\n\r\n\t/**\r\n\t * Gets the binding registry singleton.\r\n\t *\r\n\t * @returns A [[BindingRegistry]].\r\n\t */\r\n\tpublic static get instance(): BindingRegistry {\r\n\t\tconst BINDING_REGISTRY_SLOTNAME = '__CUCUMBER_TSFLOW_BINDINGREGISTRY';\r\n\r\n\t\tconst registry = (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\r\n\t\tif (!registry) {\r\n\t\t\t(global as any)[BINDING_REGISTRY_SLOTNAME] = new BindingRegistry();\r\n\t\t}\r\n\r\n\t\treturn registry || (global as any)[BINDING_REGISTRY_SLOTNAME];\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry with information about the context types required by a\r\n\t * binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t * @param contextTypes An array of [[ContextType]] that define the types of objects that\r\n\t * should be injected into the binding class during a scenario execution.\r\n\t */\r\n\tpublic registerContextTypesForClass(classPrototype: any, contextTypes?: ContextType[]): void {\r\n\t\tif (!contextTypes) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tlet targetDecorations = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetDecorations) {\r\n\t\t\ttargetDecorations = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(classPrototype, targetDecorations);\r\n\t\t}\r\n\r\n\t\ttargetDecorations.contextTypes = contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the context types that have been registered for a given binding class.\r\n\t *\r\n\t * @param classPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[ContextType]] that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getContextTypesForClass(classPrototype: any): ContextType[] {\r\n\t\tconst targetBinding = this._classBindings.get(classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.contextTypes;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the binding registry indexes with a step binding.\r\n\t *\r\n\t * @param stepBinding The step binding that is to be registered with the binding registry.\r\n\t */\r\n\tpublic registerStepBinding(stepBinding: StepBinding): void {\r\n\t\tif (!stepBinding.tags) {\r\n\t\t\tstepBinding.tags = DEFAULT_TAG;\r\n\t\t}\r\n\r\n\t\tif (stepBinding.tags !== DEFAULT_TAG && !stepBinding.tags.startsWith('@')) {\r\n\t\t\t// tslint:disable-next-line:no-console\r\n\t\t\tlogger.debug('tag should start with @; tsflow has stopped to automatically prepend @ for you.');\r\n\t\t}\r\n\r\n\t\tconst stepPattern: StepPattern = stepBinding.stepPattern\r\n\t\t\t? stepBinding.stepPattern.toString()\r\n\t\t\t: DEFAULT_STEP_PATTERN;\r\n\r\n\t\tlet tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\ttagMap = new Map<TagName, StepBinding[]>();\r\n\t\t\tthis._stepBindings.set(stepPattern, tagMap);\r\n\t\t}\r\n\r\n\t\tlet stepBindings = tagMap.get(stepBinding.tags);\r\n\r\n\t\tif (!stepBindings) {\r\n\t\t\tstepBindings = [];\r\n\t\t\ttagMap.set(stepBinding.tags, stepBindings);\r\n\t\t}\r\n\r\n\t\tif (!stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\tstepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\t// Index the step binding for the target\r\n\t\tlet targetBinding = this._classBindings.get(stepBinding.classPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\ttargetBinding = {\r\n\t\t\t\tstepBindings: [],\r\n\t\t\t\tcontextTypes: []\r\n\t\t\t};\r\n\r\n\t\t\tthis._classBindings.set(stepBinding.classPrototype, targetBinding);\r\n\t\t}\r\n\r\n\t\tif (!targetBinding.stepBindings.some(b => isSameStepBinding(stepBinding, b))) {\r\n\t\t\ttargetBinding.stepBindings.push(stepBinding);\r\n\t\t}\r\n\r\n\t\tfunction isSameStepBinding(a: StepBinding, b: StepBinding) {\r\n\t\t\t// For hooks, we need to check the binding type and method name too\r\n\t\t\tif (a.bindingType & StepBindingFlags.Hooks) {\r\n\t\t\t\treturn (\r\n\t\t\t\t\ta.callsite.filename === b.callsite.filename &&\r\n\t\t\t\t\ta.callsite.lineNumber === b.callsite.lineNumber &&\r\n\t\t\t\t\tString(a.tags) === String(b.tags) &&\r\n\t\t\t\t\tString(a.stepPattern) === String(b.stepPattern) &&\r\n\t\t\t\t\ta.bindingType === b.bindingType &&\r\n\t\t\t\t\ta.classPropertyKey === b.classPropertyKey\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\t// For step definitions, the existing check is fine\r\n\t\t\treturn (\r\n\t\t\t\ta.callsite.filename === b.callsite.filename &&\r\n\t\t\t\ta.callsite.lineNumber === b.callsite.lineNumber &&\r\n\t\t\t\tString(a.tags) === String(b.tags) &&\r\n\t\t\t\tString(a.stepPattern) === String(b.stepPattern)\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings that have been registered for a given binding class.\r\n\t *\r\n\t * @param targetPrototype The class representing the binding (constructor function).\r\n\t *\r\n\t * @returns An array of [[StepBinding]] objects that have been registered for the specified\r\n\t * binding class.\r\n\t */\r\n\tpublic getStepBindingsForTarget(targetPrototype: any): StepBinding[] {\r\n\t\tconst targetBinding = this._classBindings.get(targetPrototype);\r\n\r\n\t\tif (!targetBinding) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\treturn targetBinding.stepBindings;\r\n\t}\r\n\r\n\t/**\r\n\t * Retrieves the step bindings for a given step pattern and collection of tag names.\r\n\t *\r\n\t * @param stepPattern The step pattern to search.\r\n\t * @param tags An array of [[TagName]] to search.\r\n\t *\r\n\t * @returns An array of [[StepBinding]] that map to the given step pattern and set of tag names.\r\n\t */\r\n\tpublic getStepBindings(stepPattern: StepPattern, tags: TagName[]): StepBinding[] {\r\n\t\tconst tagMap = this._stepBindings.get(stepPattern);\r\n\r\n\t\tif (!tagMap) {\r\n\t\t\treturn [];\r\n\t\t}\r\n\r\n\t\tconst matchingStepBindings = this.mapTagNamesToStepBindings(tags, tagMap);\r\n\r\n\t\tif (matchingStepBindings.length > 0) {\r\n\t\t\treturn matchingStepBindings;\r\n\t\t}\r\n\r\n\t\treturn this.mapTagNamesToStepBindings(['*'], tagMap);\r\n\t}\r\n\r\n\tpublic getStepBindingByCucumberKey(cucumberKey: string): StepBinding | undefined {\r\n\t\tlet result: StepBinding | undefined = undefined;\r\n\r\n\t\tfor (const [_, binding] of this._classBindings) {\r\n\t\t\tfor (const stepBinding of binding.stepBindings) {\r\n\t\t\t\tif (stepBinding.cucumberKey === cucumberKey) {\r\n\t\t\t\t\tresult = stepBinding;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (result) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the SupportCodeLibrary from Cucumber with\r\n\t * callsite information from tsflow bindings\r\n\t * @param library\r\n\t * @returns\r\n\t */\r\n\tpublic updateSupportCodeLibrary = (library: SupportCodeLibrary): SupportCodeLibrary => {\r\n\t\tthis._classBindings.forEach(binding => {\r\n\t\t\tbinding.stepBindings.forEach(stepBinding => {\r\n\t\t\t\tlet cucumberDefinition: any | undefined = undefined;\r\n\t\t\t\tswitch (stepBinding.bindingType) {\r\n\t\t\t\t\tcase StepBindingFlags.beforeAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.before:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.beforeStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.beforeTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.given:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.when:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.then:\r\n\t\t\t\t\t\tcucumberDefinition = library.stepDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterStep:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestStepHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.after:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestCaseHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase StepBindingFlags.afterAll:\r\n\t\t\t\t\t\tcucumberDefinition = library.afterTestRunHookDefinitions.find(\r\n\t\t\t\t\t\t\ts => (s.options as any).cucumberKey === stepBinding.cucumberKey\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tif (cucumberDefinition) {\r\n\t\t\t\t\tcucumberDefinition.line = stepBinding.callsite.lineNumber;\r\n\t\t\t\t\tcucumberDefinition.uri = stepBinding.callsite.filename;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t\treturn library;\r\n\t};\r\n\r\n\t/**\r\n\t * Maps an array of tag names to an array of associated step bindings.\r\n\t *\r\n\t * @param tags An array of [[TagName]].\r\n\t * @param tagMap The map of [[TagName]] -> [[StepBinding]] to use when mapping.\r\n\t *\r\n\t * @returns An array of [[StepBinding]].\r\n\t */\r\n\tprivate mapTagNamesToStepBindings(tags: TagName[], tagMap: Map<TagName, StepBinding[]>): StepBinding[] {\r\n\t\tconst matchingStepBindings: (StepBinding | undefined)[] = _.flatten(_.map(tags, tag => tagMap.get(tag)));\r\n\r\n\t\treturn _.reject(matchingStepBindings, stepBinding => stepBinding === undefined) as StepBinding[];\r\n\t}\r\n}\r\n"]}
@@ -83,14 +83,15 @@ function checkTag(tag) {
83
83
  function createDecoratorFactory(flag, callSite, tag, timeout) {
84
84
  if (global.experimentalDecorators) {
85
85
  return (target, propertyKey, descriptor) => {
86
+ const stepFunction = descriptor?.value || target[propertyKey];
86
87
  const stepBinding = {
87
88
  stepPattern: '',
88
89
  bindingType: flag,
89
90
  classPrototype: target,
90
91
  classPropertyKey: propertyKey,
91
- stepFunction: target[propertyKey],
92
+ stepFunction,
92
93
  stepIsStatic: false,
93
- stepArgsLength: target[propertyKey].length,
94
+ stepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access
94
95
  tags: tag,
95
96
  timeout: timeout,
96
97
  callsite: callSite,
@@ -121,7 +122,7 @@ function createDecoratorFactory(flag, callSite, tag, timeout) {
121
122
  if (tag) {
122
123
  stepBinding.tags = checkTag(tag);
123
124
  }
124
- (0, binding_context_1.addStepBinding)(context, stepBinding);
125
+ (0, binding_context_1.collectStepBinding)(stepBinding);
125
126
  return;
126
127
  };
127
128
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hook-decorators.js","sourceRoot":"","sources":["../../src/bindings/hook-decorators.ts"],"names":[],"mappings":";;;;;AAWA,8BAGC;AAQD,wBAGC;AAQD,gCAGC;AAQD,4BAGC;AAQD,sBAGC;AAQD,8BAGC;AArED,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAAsE;AAEtE;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,OAAgB;IACzC,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC;AACD;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAa,EAAE,OAAgB;IACrD,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACjF,CAAC;AACD;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAa,EAAE,OAAgB;IACzD,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAA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Ac,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM;gBAC1C,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,IAAA,oBAAS,GAAE,CAAC,GAAG,EAAE;aAC9B,CAAC;YAEF,IAAI,GAAG,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,IAAA,mCAAiB,EAAC,WAAW,CAAC,CAAC;YAE/B,OAAO,UAAU,CAAC;QACnB,CAAC,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO,SAAS,aAAa,CAAC,MAAgB,EAAE,OAAoC;YACnF,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,EAAE;gBACf,WAAW,EAAE,IAAI;gBACjB,cAAc,EAAE,SAAS;gBACzB,gBAAgB,EAAE,OAAO,CAAC,IAAI;gBAC9B,YAAY,EAAE,MAAM;gBACpB,YAAY,EAAE,OAAO,CAAC,MAAM;gBAC5B,cAAc,EAAE,MAAM,CAAC,MAAM;gBAC7B,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,IAAA,oBAAS,GAAE,CAAC,GAAG,EAAE;aAC9B,CAAC;YAEF,IAAI,GAAG,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,IAAA,gCAAc,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAErC,OAAO;QACR,CAAC,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding, addStepBindingExp } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Before All Scenario' step. The function is\r\n * executed before all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Scenario' step. The function is\r\n * executed before each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function before(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.before, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Step' step. The function is\r\n * executed before each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeStep, callSite, tags, timeout);\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as an 'After All Scenario' step. The function is\r\n * executed after all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as an 'After Scenario' step. The function is\r\n * executed after each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function after(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.after, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'After Step' step. The function is\r\n * executed after each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterStep, callSite, tags, timeout);\r\n}\r\n\r\nfunction checkTag(tag: string): string {\r\n\treturn tag;\r\n}\r\n\r\nfunction createDecoratorFactory(flag: StepBindingFlags, callSite: Callsite, tag?: string, timeout?: number) {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: '',\r\n\t\t\t\tbindingType: flag,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction: target[propertyKey],\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: target[propertyKey].length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\tcallsite: callSite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tif (tag) {\r\n\t\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t\t}\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function hookDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: '',\r\n\t\t\t\tbindingType: flag,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\tcallsite: callSite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tif (tag) {\r\n\t\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t\t}\r\n\t\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"hook-decorators.js","sourceRoot":"","sources":["../../src/bindings/hook-decorators.ts"],"names":[],"mappings":";;;;;AAWA,8BAGC;AAQD,wBAGC;AAQD,gCAGC;AAQD,4BAGC;AAQD,sBAGC;AAQD,8BAGC;AArED,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAA0E;AAE1E;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,OAAgB;IACzC,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACzF,CAAC;AACD;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,IAAa,EAAE,OAAgB;IACrD,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACjF,CAAC;AACD;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAa,EAAE,OAAgB;IACzD,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACrF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,OAAgB;IACxC,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,OAAO,sBAAsB,CAAC,+BAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC;AAC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AC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,IAAA,mCAAiB,EAAC,WAAW,CAAC,CAAC;YAE/B,OAAO,UAAU,CAAC;QACnB,CAAC,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO,SAAS,aAAa,CAAC,MAAgB,EAAE,OAAoC;YACnF,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,EAAE;gBACf,WAAW,EAAE,IAAI;gBACjB,cAAc,EAAE,SAAS;gBACzB,gBAAgB,EAAE,OAAO,CAAC,IAAI;gBAC9B,YAAY,EAAE,MAAM;gBACpB,YAAY,EAAE,OAAO,CAAC,MAAM;gBAC5B,cAAc,EAAE,MAAM,CAAC,MAAM;gBAC7B,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,QAAQ;gBAClB,WAAW,EAAE,IAAA,oBAAS,GAAE,CAAC,GAAG,EAAE;aAC9B,CAAC;YAEF,IAAI,GAAG,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YAED,IAAA,oCAAkB,EAAC,WAAW,CAAC,CAAC;YAEhC,OAAO;QACR,CAAC,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { collectStepBinding, addStepBindingExp } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Before All Scenario' step. The function is\r\n * executed before all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Scenario' step. The function is\r\n * executed before each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function before(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.before, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'Before Step' step. The function is\r\n * executed before each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function beforeStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.beforeStep, callSite, tags, timeout);\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as an 'After All Scenario' step. The function is\r\n * executed after all scenarios are executed.\r\n *\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterAll(timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterAll, callSite, undefined, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as an 'After Scenario' step. The function is\r\n * executed after each scenario.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function after(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.after, callSite, tags, timeout);\r\n}\r\n/**\r\n * A method decorator that marks the associated function as a 'After Step' step. The function is\r\n * executed after each step.\r\n *\r\n * @param tags Optional tag or tags associated with a scenario.\r\n * @param timeout Optional timeout in milliseconds\r\n */\r\nexport function afterStep(tags?: string, timeout?: number): any {\r\n\tconst callSite = Callsite.capture();\r\n\treturn createDecoratorFactory(StepBindingFlags.afterStep, callSite, tags, timeout);\r\n}\r\n\r\nfunction checkTag(tag: string): string {\r\n\treturn tag;\r\n}\r\n\r\nfunction createDecoratorFactory(flag: StepBindingFlags, callSite: Callsite, tag?: string, timeout?: number) {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: '',\r\n\t\t\t\tbindingType: flag,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\tcallsite: callSite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tif (tag) {\r\n\t\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t\t}\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function hookDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: '',\r\n\t\t\t\tbindingType: flag,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\tcallsite: callSite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tif (tag) {\r\n\t\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t\t}\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
@@ -21,14 +21,15 @@ function given(stepPattern, tag, timeout, wrapperOption) {
21
21
  const callsite = our_callsite_1.Callsite.capture();
22
22
  if (global.experimentalDecorators) {
23
23
  return (target, propertyKey, descriptor) => {
24
+ const stepFunction = descriptor?.value || target[propertyKey];
24
25
  const stepBinding = {
25
26
  stepPattern: stepPattern,
26
27
  bindingType: step_binding_1.StepBindingFlags.given,
27
28
  classPrototype: target,
28
29
  classPropertyKey: propertyKey,
29
- stepFunction: target[propertyKey],
30
+ stepFunction,
30
31
  stepIsStatic: false,
31
- stepArgsLength: target[propertyKey].length,
32
+ stepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access
32
33
  tags: tag,
33
34
  timeout: timeout,
34
35
  wrapperOption: wrapperOption,
@@ -55,7 +56,7 @@ function given(stepPattern, tag, timeout, wrapperOption) {
55
56
  callsite: callsite,
56
57
  cucumberKey: (0, short_uuid_1.default)().new()
57
58
  };
58
- (0, binding_context_1.addStepBinding)(context, stepBinding);
59
+ (0, binding_context_1.collectStepBinding)(stepBinding);
59
60
  return;
60
61
  };
61
62
  }
@@ -71,14 +72,15 @@ function when(stepPattern, tag, timeout, wrapperOption) {
71
72
  const callsite = our_callsite_1.Callsite.capture();
72
73
  if (global.experimentalDecorators) {
73
74
  return (target, propertyKey, descriptor) => {
75
+ const stepFunction = descriptor?.value || target[propertyKey];
74
76
  const stepBinding = {
75
77
  stepPattern: stepPattern,
76
78
  bindingType: step_binding_1.StepBindingFlags.when,
77
79
  classPrototype: target,
78
80
  classPropertyKey: propertyKey,
79
- stepFunction: target[propertyKey],
81
+ stepFunction,
80
82
  stepIsStatic: false,
81
- stepArgsLength: target[propertyKey].length,
83
+ stepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access
82
84
  tags: tag,
83
85
  timeout: timeout,
84
86
  wrapperOption: wrapperOption,
@@ -105,7 +107,7 @@ function when(stepPattern, tag, timeout, wrapperOption) {
105
107
  callsite: callsite,
106
108
  cucumberKey: (0, short_uuid_1.default)().new()
107
109
  };
108
- (0, binding_context_1.addStepBinding)(context, stepBinding);
110
+ (0, binding_context_1.collectStepBinding)(stepBinding);
109
111
  return;
110
112
  };
111
113
  }
@@ -121,14 +123,15 @@ function then(stepPattern, tag, timeout, wrapperOption) {
121
123
  const callsite = our_callsite_1.Callsite.capture();
122
124
  if (global.experimentalDecorators) {
123
125
  return (target, propertyKey, descriptor) => {
126
+ const stepFunction = descriptor?.value || target[propertyKey];
124
127
  const stepBinding = {
125
128
  stepPattern: stepPattern,
126
129
  bindingType: step_binding_1.StepBindingFlags.then,
127
130
  classPrototype: target,
128
131
  classPropertyKey: propertyKey,
129
- stepFunction: target[propertyKey],
132
+ stepFunction,
130
133
  stepIsStatic: false,
131
- stepArgsLength: target[propertyKey].length,
134
+ stepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access
132
135
  tags: tag,
133
136
  timeout: timeout,
134
137
  wrapperOption: wrapperOption,
@@ -155,7 +158,7 @@ function then(stepPattern, tag, timeout, wrapperOption) {
155
158
  callsite: callsite,
156
159
  cucumberKey: (0, short_uuid_1.default)().new()
157
160
  };
158
- (0, binding_context_1.addStepBinding)(context, stepBinding);
161
+ (0, binding_context_1.collectStepBinding)(stepBinding);
159
162
  return;
160
163
  };
161
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"step-decorators.js","sourceRoot":"","sources":["../../src/bindings/step-decorators.ts"],"names":[],"mappings":";;;;;AAYA,sBA2CC;AASD,oBA4CC;AASD,oBA4CC;AAjKD,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAAsE;AAEtE;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,WAA4B,EAAE,GAAY,EAAE,OAAgB,EAAE,aAAmB;IACtG,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAW,EAAE,WAA4B,EAAE,UAAsC,EAAE,EAAE;YAC/F,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,+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IAAA,oBAAS,GAAE,CAAC,GAAG,EAAE;aAC9B,CAAC;YACF,IAAA,gCAAc,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAErC,OAAO;QACR,CAAC,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding, addStepBindingExp } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Given' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction: target[propertyKey],\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: target[propertyKey].length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function givenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'When' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction: target[propertyKey],\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: target[propertyKey].length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function whenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Then' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction: target[propertyKey],\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: target[propertyKey].length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function thenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"step-decorators.js","sourceRoot":"","sources":["../../src/bindings/step-decorators.ts"],"names":[],"mappings":";;;;;AAYA,sBA8CC;AASD,oBA+CC;AASD,oBA+CC;AA1KD,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAA0F;AAE1F;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,WAA4B,EAAE,GAAY,EAAE,OAAgB,EAAE,aAAmB;IACtG,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAW,EAAE,WAA4B,EAAE,UAAsC,EAAE,EAAE;YAC/F,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9D,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,+BAAgB,CAAC,KAAK;gBACnC,cAAc,EAAE,MAAM;gBACtB,gBAAgB,EAAE,WAAW;gBAC7B,YAAY;gBACZ,YAAY,EAAE,KAAK;gBACnB,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;gBACtE,IAAI,EAAE,GAAG;gBAC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CAAkB,EAAC,WAAW,CAAC,CAAC;YAEhC,OAAO;QACR,CAAC,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding, addStepBindingExp, collectStepBinding } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Given' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function givenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'When' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function whenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Then' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function thenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
@@ -74,7 +74,6 @@ const ArgvParser = {
74
74
  .option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
75
75
  .option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', val => ArgvParser.validateCountOption(val, '--parallel'))
76
76
  .option('--publish', 'Publish a report to https://reports.cucumber.io')
77
- .option('--publish-quiet', "Don't print information banner about publishing reports")
78
77
  .option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect)
79
78
  .option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect)
80
79
  .option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', val => ArgvParser.validateCountOption(val, '--retry'))
@@ -83,7 +82,7 @@ const ArgvParser = {
83
82
  .option('--strict', 'fail if there are pending steps')
84
83
  .option('--no-strict', 'succeed even if there are pending steps')
85
84
  .option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags)
86
- .option('--transpiler <ESNODE|TSNODE|ESVUE|TSVUE>', `built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\n
85
+ .option('--transpiler <ES-NODE|TS-NODE|ES-VUE|TS-VUE|TS-VUE-ESM|ES-NODE-ESM|ES-VUE-ESM>', `built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\n
87
86
  Vue versions of the transpilers add a hook for .vue transforms and initialize jsdom globally.\n
88
87
  Default: ESNODE (esbuild without Vue support)`)
89
88
  .option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'));
@@ -1 +1 @@
1
- {"version":3,"file":"argv-parser.js","sourceRoot":"","sources":["../../src/cli/argv-parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAoC;AACpC,gEAAiC;AACjC,gDAAwB;AACxB,+CAA6C;AAC7C,0EAA+E;AAC/E,wCAAqC;AAwBrC,MAAM,UAAU,GAAG;IAClB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAChC,IAAI,GAAG,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACvB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC9C,IAAI,GAAW,CAAC;YAChB,IAAI,CAAC;gBACJ,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,CAAC,GAAU,KAAc,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAC;YACxE,CAAC;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,sCAAsC,GAAG,EAAE,CAAC,CAAC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kB,CAAC,OAAO,CAC3B;aACA,MAAM,CACN,gCAAgC,EAChC,0DAA0D,EACzD,UAAkB,CAAC,OAAO,CAC3B;aACA,MAAM,CACN,6BAA6B,EAC7B,sEAAsE,EACtE,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACrD;aACA,MAAM,CACN,iCAAiC,EACjC;wDACoD,EACpD,UAAU,CAAC,SAAS,CACpB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACN,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACpB;aACA,MAAM,CACN,0CAA0C,EAC1C;;kDAE8C,CAC9C;aACA,MAAM,CACN,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC1C,CAAC;QAEH,OAAO,CAAC,WAAW,CAClB,UAAU,EACV,6FAA6F,CAC7F,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1G,MAAM,aAAa,GAAkC,YAAY,CAAC;QAClE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QACpC,CAAC;QAED,OAAO;YACN,OAAO,EAAE;gBACR,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACP;YACD,aAAa;SACb,CAAC;IACH,CAAC;CACD,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import { Command } from 'commander';\r\nimport merge from 'lodash.merge';\r\nimport path from 'path';\r\nimport { dialects } from '@cucumber/gherkin';\r\nimport { documentation } from '@cucumber/cucumber/lib/formatter/builtin/index';\r\nimport { version } from '../version';\r\nimport { IConfiguration } from '@cucumber/cucumber/lib/configuration/types';\r\n\r\nexport interface IParsedArgvOptions {\r\n\tconfig?: string;\r\n\ti18nKeywords?: string;\r\n\ti18nLanguages?: boolean;\r\n\tprofile?: string[];\r\n}\r\n\r\nexport interface ITsflowConfiguration extends IConfiguration {\r\n\tdebugFile: string;\r\n\ttranspiler: string;\r\n\tenableVueStyle: boolean;\r\n\texperimentalDecorators: boolean;\r\n}\r\n\r\nexport interface IParsedArgv {\r\n\toptions: IParsedArgvOptions;\r\n\tconfiguration: Partial<ITsflowConfiguration>;\r\n}\r\n\r\ntype IRawArgvOptions = Partial<Omit<ITsflowConfiguration, 'paths'>> & IParsedArgvOptions;\r\n\r\nconst ArgvParser = {\r\n\tcollect<T>(val: T, memo: T[] = []): T[] | undefined {\r\n\t\tif (val) {\r\n\t\t\treturn [...memo, val];\r\n\t\t}\r\n\t\treturn undefined;\r\n\t},\r\n\r\n\tmergeJson(option: string): (str: string, memo?: object) => object {\r\n\t\treturn function (str: string, memo: object = {}) {\r\n\t\t\tlet val: object;\r\n\t\t\ttry {\r\n\t\t\t\tval = JSON.parse(str);\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconst e: Error = error as Error;\r\n\t\t\t\tthrow new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);\r\n\t\t\t}\r\n\t\t\tif (typeof val !== 'object' || Array.isArray(val)) {\r\n\t\t\t\tthrow new Error(`${option} must be passed JSON of an object: ${str}`);\r\n\t\t\t}\r\n\t\t\treturn merge(memo, val);\r\n\t\t};\r\n\t},\r\n\r\n\tmergeTags(value: string, memo?: string): string {\r\n\t\treturn memo ? `${memo} and (${value})` : `(${value})`;\r\n\t},\r\n\r\n\tvalidateCountOption(value: string, optionName: string): number {\r\n\t\tconst numericValue = parseInt(value);\r\n\t\tif (isNaN(numericValue) || numericValue < 0) {\r\n\t\t\tthrow new Error(`${optionName} must be a non negative integer`);\r\n\t\t}\r\n\t\treturn numericValue;\r\n\t},\r\n\r\n\tvalidateLanguage(value: string): string {\r\n\t\tif (!Object.keys(dialects).includes(value)) {\r\n\t\t\tthrow new Error(`Unsupported ISO 639-1: ${value}`);\r\n\t\t}\r\n\t\treturn value;\r\n\t},\r\n\r\n\tparse(argv: string[]): IParsedArgv {\r\n\t\tconst program = new Command(path.basename(argv[1]));\r\n\r\n\t\tprogram\r\n\t\t\t.storeOptionsAsProperties(false)\r\n\t\t\t.usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\r\n\t\t\t.version(version, '-v, --version')\r\n\t\t\t.option('-b, --backtrace', 'show full backtrace for errors')\r\n\t\t\t.option('-c, --config <PATH>', 'specify configuration file')\r\n\t\t\t.option('-d, --dry-run', 'invoke formatters without executing steps')\r\n\t\t\t.option('--debug-file <STRING>', 'path to a file with steps for debugging')\r\n\t\t\t.option('--enable-vue-style', 'Enable Vue Style block when compiling Vue SFC. Defaults to false.')\r\n\t\t\t.option(\r\n\t\t\t\t'--exit, --force-exit',\r\n\t\t\t\t'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--experimental-decorators',\r\n\t\t\t\t'Enable TypeScript Experimental Decorators when transpiling. Defaults to false.'\r\n\t\t\t)\r\n\t\t\t.option('--fail-fast', 'abort the run on first failure')\r\n\t\t\t.option(\r\n\t\t\t\t'-f, --format <TYPE[:PATH]>',\r\n\t\t\t\t'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\r\n\t\t\t\t\tObject.entries(documentation).reduce(\r\n\t\t\t\t\t\t(previous, [key, description]) => previous + ` ${key}: ${description}\\n`,\r\n\t\t\t\t\t\t''\r\n\t\t\t\t\t),\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--format-options <JSON>',\r\n\t\t\t\t'provide options for formatters (repeatable)',\r\n\t\t\t\tArgvParser.mergeJson('--format-options')\r\n\t\t\t)\r\n\t\t\t.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)\r\n\t\t\t.option('--i18n-languages', 'list languages')\r\n\t\t\t.option(\r\n\t\t\t\t'-i, --import <GLOB|DIR|FILE>',\r\n\t\t\t\t'import files before executing features (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option('--language <ISO 639-1>', 'provide the default language for feature files')\r\n\t\t\t.option(\r\n\t\t\t\t'--name <REGEXP>',\r\n\t\t\t\t'only execute the scenarios with name matching the expression (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')\r\n\t\t\t.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', (ArgvParser as any).collect, [])\r\n\t\t\t.option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', val =>\r\n\t\t\t\tArgvParser.validateCountOption(val, '--parallel')\r\n\t\t\t)\r\n\t\t\t.option('--publish', 'Publish a report to https://reports.cucumber.io')\r\n\t\t\t.option('--publish-quiet', \"Don't print information banner about publishing reports\")\r\n\t\t\t.option(\r\n\t\t\t\t'-r, --require <GLOB|DIR|FILE>',\r\n\t\t\t\t'require files before executing features (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--require-module <NODE_MODULE>',\r\n\t\t\t\t'require node modules before requiring files (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--retry <NUMBER_OF_RETRIES>',\r\n\t\t\t\t'specify the number of times to retry failing test cases (default: 0)',\r\n\t\t\t\tval => ArgvParser.validateCountOption(val, '--retry')\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--retry-tag-filter <EXPRESSION>',\r\n\t\t\t\t`only retries the features or scenarios with tags matching the expression (repeatable).\r\n This option requires '--retry' to be specified.`,\r\n\t\t\t\tArgvParser.mergeTags\r\n\t\t\t)\r\n\t\t\t.option('--strict', 'fail if there are pending steps')\r\n\t\t\t.option('--no-strict', 'succeed even if there are pending steps')\r\n\t\t\t.option(\r\n\t\t\t\t'-t, --tags <EXPRESSION>',\r\n\t\t\t\t'only execute the features or scenarios with tags matching the expression (repeatable)',\r\n\t\t\t\tArgvParser.mergeTags\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--transpiler <ESNODE|TSNODE|ESVUE|TSVUE>',\r\n\t\t\t\t`built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\\n\r\n\t\t\t\tVue versions of the transpilers add a hook for .vue transforms and initialize jsdom globally.\\n\r\n\t\t\t\tDefault: ESNODE (esbuild without Vue support)`\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--world-parameters <JSON>',\r\n\t\t\t\t'provide parameters that will be passed to the world constructor (repeatable)',\r\n\t\t\t\tArgvParser.mergeJson('--world-parameters')\r\n\t\t\t);\r\n\r\n\t\tprogram.addHelpText(\r\n\t\t\t'afterAll',\r\n\t\t\t'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\r\n\t\t);\r\n\r\n\t\tprogram.parse(argv);\r\n\t\tconst { config, i18nKeywords, i18nLanguages, profile, ...regularStuff }: IRawArgvOptions = program.opts();\r\n\t\tconst configuration: Partial<ITsflowConfiguration> = regularStuff;\r\n\t\tif (program.args.length > 0) {\r\n\t\t\tconfiguration.paths = program.args;\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\toptions: {\r\n\t\t\t\tconfig,\r\n\t\t\t\ti18nKeywords,\r\n\t\t\t\ti18nLanguages,\r\n\t\t\t\tprofile\r\n\t\t\t},\r\n\t\t\tconfiguration\r\n\t\t};\r\n\t}\r\n};\r\n\r\nexport default ArgvParser;\r\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E,MAAM,CACN,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACpB;aACA,MAAM,CACN,gFAAgF,EAChF;;kDAE8C,CAC9C;aACA,MAAM,CACN,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC1C,CAAC;QAEH,OAAO,CAAC,WAAW,CAClB,UAAU,EACV,6FAA6F,CAC7F,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1G,MAAM,aAAa,GAAkC,YAAY,CAAC;QAClE,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QACpC,CAAC;QAED,OAAO;YACN,OAAO,EAAE;gBACR,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACP;YACD,aAAa;SACb,CAAC;IACH,CAAC;CACD,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import { Command } from 'commander';\r\nimport merge from 'lodash.merge';\r\nimport path from 'path';\r\nimport { dialects } from '@cucumber/gherkin';\r\nimport { documentation } from '@cucumber/cucumber/lib/formatter/builtin/index';\r\nimport { version } from '../version';\r\nimport { IConfiguration } from '@cucumber/cucumber/lib/configuration/types';\r\n\r\nexport interface IParsedArgvOptions {\r\n\tconfig?: string;\r\n\ti18nKeywords?: string;\r\n\ti18nLanguages?: boolean;\r\n\tprofile?: string[];\r\n}\r\n\r\nexport interface ITsflowConfiguration extends IConfiguration {\r\n\tdebugFile: string;\r\n\ttranspiler: string;\r\n\tenableVueStyle: boolean;\r\n\texperimentalDecorators: boolean;\r\n}\r\n\r\nexport interface IParsedArgv {\r\n\toptions: IParsedArgvOptions;\r\n\tconfiguration: Partial<ITsflowConfiguration>;\r\n}\r\n\r\ntype IRawArgvOptions = Partial<Omit<ITsflowConfiguration, 'paths'>> & IParsedArgvOptions;\r\n\r\nconst ArgvParser = {\r\n\tcollect<T>(val: T, memo: T[] = []): T[] | undefined {\r\n\t\tif (val) {\r\n\t\t\treturn [...memo, val];\r\n\t\t}\r\n\t\treturn undefined;\r\n\t},\r\n\r\n\tmergeJson(option: string): (str: string, memo?: object) => object {\r\n\t\treturn function (str: string, memo: object = {}) {\r\n\t\t\tlet val: object;\r\n\t\t\ttry {\r\n\t\t\t\tval = JSON.parse(str);\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconst e: Error = error as Error;\r\n\t\t\t\tthrow new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);\r\n\t\t\t}\r\n\t\t\tif (typeof val !== 'object' || Array.isArray(val)) {\r\n\t\t\t\tthrow new Error(`${option} must be passed JSON of an object: ${str}`);\r\n\t\t\t}\r\n\t\t\treturn merge(memo, val);\r\n\t\t};\r\n\t},\r\n\r\n\tmergeTags(value: string, memo?: string): string {\r\n\t\treturn memo ? `${memo} and (${value})` : `(${value})`;\r\n\t},\r\n\r\n\tvalidateCountOption(value: string, optionName: string): number {\r\n\t\tconst numericValue = parseInt(value);\r\n\t\tif (isNaN(numericValue) || numericValue < 0) {\r\n\t\t\tthrow new Error(`${optionName} must be a non negative integer`);\r\n\t\t}\r\n\t\treturn numericValue;\r\n\t},\r\n\r\n\tvalidateLanguage(value: string): string {\r\n\t\tif (!Object.keys(dialects).includes(value)) {\r\n\t\t\tthrow new Error(`Unsupported ISO 639-1: ${value}`);\r\n\t\t}\r\n\t\treturn value;\r\n\t},\r\n\r\n\tparse(argv: string[]): IParsedArgv {\r\n\t\tconst program = new Command(path.basename(argv[1]));\r\n\r\n\t\tprogram\r\n\t\t\t.storeOptionsAsProperties(false)\r\n\t\t\t.usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\r\n\t\t\t.version(version, '-v, --version')\r\n\t\t\t.option('-b, --backtrace', 'show full backtrace for errors')\r\n\t\t\t.option('-c, --config <PATH>', 'specify configuration file')\r\n\t\t\t.option('-d, --dry-run', 'invoke formatters without executing steps')\r\n\t\t\t.option('--debug-file <STRING>', 'path to a file with steps for debugging')\r\n\t\t\t.option('--enable-vue-style', 'Enable Vue Style block when compiling Vue SFC. Defaults to false.')\r\n\t\t\t.option(\r\n\t\t\t\t'--exit, --force-exit',\r\n\t\t\t\t'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--experimental-decorators',\r\n\t\t\t\t'Enable TypeScript Experimental Decorators when transpiling. Defaults to false.'\r\n\t\t\t)\r\n\t\t\t.option('--fail-fast', 'abort the run on first failure')\r\n\t\t\t.option(\r\n\t\t\t\t'-f, --format <TYPE[:PATH]>',\r\n\t\t\t\t'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\r\n\t\t\t\t\tObject.entries(documentation).reduce(\r\n\t\t\t\t\t\t(previous, [key, description]) => previous + ` ${key}: ${description}\\n`,\r\n\t\t\t\t\t\t''\r\n\t\t\t\t\t),\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--format-options <JSON>',\r\n\t\t\t\t'provide options for formatters (repeatable)',\r\n\t\t\t\tArgvParser.mergeJson('--format-options')\r\n\t\t\t)\r\n\t\t\t.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)\r\n\t\t\t.option('--i18n-languages', 'list languages')\r\n\t\t\t.option(\r\n\t\t\t\t'-i, --import <GLOB|DIR|FILE>',\r\n\t\t\t\t'import files before executing features (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option('--language <ISO 639-1>', 'provide the default language for feature files')\r\n\t\t\t.option(\r\n\t\t\t\t'--name <REGEXP>',\r\n\t\t\t\t'only execute the scenarios with name matching the expression (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')\r\n\t\t\t.option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', (ArgvParser as any).collect, [])\r\n\t\t\t.option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', val =>\r\n\t\t\t\tArgvParser.validateCountOption(val, '--parallel')\r\n\t\t\t)\r\n\t\t\t.option('--publish', 'Publish a report to https://reports.cucumber.io')\r\n\t\t\t.option(\r\n\t\t\t\t'-r, --require <GLOB|DIR|FILE>',\r\n\t\t\t\t'require files before executing features (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--require-module <NODE_MODULE>',\r\n\t\t\t\t'require node modules before requiring files (repeatable)',\r\n\t\t\t\t(ArgvParser as any).collect\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--retry <NUMBER_OF_RETRIES>',\r\n\t\t\t\t'specify the number of times to retry failing test cases (default: 0)',\r\n\t\t\t\tval => ArgvParser.validateCountOption(val, '--retry')\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--retry-tag-filter <EXPRESSION>',\r\n\t\t\t\t`only retries the features or scenarios with tags matching the expression (repeatable).\r\n This option requires '--retry' to be specified.`,\r\n\t\t\t\tArgvParser.mergeTags\r\n\t\t\t)\r\n\t\t\t.option('--strict', 'fail if there are pending steps')\r\n\t\t\t.option('--no-strict', 'succeed even if there are pending steps')\r\n\t\t\t.option(\r\n\t\t\t\t'-t, --tags <EXPRESSION>',\r\n\t\t\t\t'only execute the features or scenarios with tags matching the expression (repeatable)',\r\n\t\t\t\tArgvParser.mergeTags\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--transpiler <ES-NODE|TS-NODE|ES-VUE|TS-VUE|TS-VUE-ESM|ES-NODE-ESM|ES-VUE-ESM>',\r\n\t\t\t\t`built-in transpiler to use. ESxxx transpilers use esbuild and TSxxx transpilers use typescript.\\n\r\n\t\t\t\tVue versions of the transpilers add a hook for .vue transforms and initialize jsdom globally.\\n\r\n\t\t\t\tDefault: ESNODE (esbuild without Vue support)`\r\n\t\t\t)\r\n\t\t\t.option(\r\n\t\t\t\t'--world-parameters <JSON>',\r\n\t\t\t\t'provide parameters that will be passed to the world constructor (repeatable)',\r\n\t\t\t\tArgvParser.mergeJson('--world-parameters')\r\n\t\t\t);\r\n\r\n\t\tprogram.addHelpText(\r\n\t\t\t'afterAll',\r\n\t\t\t'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\r\n\t\t);\r\n\r\n\t\tprogram.parse(argv);\r\n\t\tconst { config, i18nKeywords, i18nLanguages, profile, ...regularStuff }: IRawArgvOptions = program.opts();\r\n\t\tconst configuration: Partial<ITsflowConfiguration> = regularStuff;\r\n\t\tif (program.args.length > 0) {\r\n\t\t\tconfiguration.paths = program.args;\r\n\t\t}\r\n\r\n\t\treturn {\r\n\t\t\toptions: {\r\n\t\t\t\tconfig,\r\n\t\t\t\ti18nKeywords,\r\n\t\t\t\ti18nLanguages,\r\n\t\t\t\tprofile\r\n\t\t\t},\r\n\t\t\tconfiguration\r\n\t\t};\r\n\t}\r\n};\r\n\r\nexport default ArgvParser;\r\n"]}
@@ -66,7 +66,7 @@ class ChildProcessWorker {
66
66
  for (const specifier of supportCodeCoordinates.loaders) {
67
67
  (0, node_module_1.register)(specifier, (0, node_url_1.pathToFileURL)('./'));
68
68
  }
69
- for (const path of supportCodeCoordinates.importPaths) {
69
+ for (const path of importPaths) {
70
70
  await import((0, node_url_1.pathToFileURL)(path).toString());
71
71
  }
72
72
  // Finalize the support code library with IDs passed in and
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA2C;AAC3C,uCAAy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L } from 'node:url';\r\nimport { register } from 'node:module';\r\nimport { Envelope, IdGenerator } from '@cucumber/messages';\r\nimport supportCodeLibraryBuilder from '@cucumber/cucumber/lib/support_code_library_builder/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport tryRequire from '@cucumber/cucumber/lib/try_require';\r\nimport { Worker } from '../worker';\r\nimport { WorkerToCoordinatorEvent, RunCommand } from '@cucumber/cucumber/lib/runtime/parallel/types';\r\nimport logger from '../../utils/logger';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/paths';\r\nimport { BindingRegistry } from '../../bindings/binding-registry';\r\nimport { InitializeTsflowCommand, CoordinatorToWorkerCommand, TsFlowRuntimeOptions } from '../types';\r\nimport MessageCollector from '../message-collector';\r\n\r\nconst { uuid } = IdGenerator;\r\n\r\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void;\r\ntype IMessageSender = (command: WorkerToCoordinatorEvent) => void;\r\n\r\n/**\r\n * Represents a child process running in parallel executions\r\n */\r\nexport class ChildProcessWorker {\r\n\tprivate readonly cwd: string;\r\n\tprivate readonly exit: IExitFunction;\r\n\r\n\tprivate readonly id: string;\r\n\tprivate readonly eventBroadcaster: EventEmitter;\r\n\tprivate readonly newId: IdGenerator.NewId;\r\n\tprivate readonly sendMessage: IMessageSender;\r\n\tprivate options!: TsFlowRuntimeOptions;\r\n\tprivate supportCodeLibrary!: SupportCodeLibrary;\r\n\tprivate worker!: Worker;\r\n\r\n\tconstructor({\r\n\t\tcwd,\r\n\t\texit,\r\n\t\tid,\r\n\t\tsendMessage,\r\n\t\texperimentalDecorators\r\n\t}: {\r\n\t\tcwd: string;\r\n\t\texit: IExitFunction;\r\n\t\tid: string;\r\n\t\tsendMessage: IMessageSender;\r\n\t\texperimentalDecorators: boolean;\r\n\t}) {\r\n\t\tthis.id = id;\r\n\t\tthis.newId = uuid();\r\n\t\tthis.cwd = cwd;\r\n\t\tthis.exit = exit;\r\n\t\tthis.sendMessage = sendMessage;\r\n\t\tthis.eventBroadcaster = new EventEmitter();\r\n\r\n\t\t// initialize a message collector for this process to handle our\r\n\t\t// integration with event data\r\n\t\tglobal.messageCollector = new MessageCollector(this.eventBroadcaster);\r\n\r\n\t\t// initialize the global experimentalDecorators setting\r\n\t\tglobal.experimentalDecorators = experimentalDecorators;\r\n\r\n\t\t// pass any envelope messages up to the parent process to keep our main\r\n\t\t// message collector in sync with this one.\r\n\t\tthis.eventBroadcaster.on('envelope', (envelope: Envelope) => this.sendMessage({ type: 'ENVELOPE', envelope }));\r\n\t}\r\n\r\n\t/**\r\n\t * Initialize this child process worker\r\n\t */\r\n\tasync initialize({\r\n\t\tsupportCodeCoordinates,\r\n\t\tsupportCodeIds,\r\n\t\toptions,\r\n\t\tmessageData\r\n\t}: InitializeTsflowCommand): Promise<void> {\r\n\t\t// reset the message collector with message data passed in\r\n\t\tglobal.messageCollector.reset(messageData);\r\n\r\n\t\t// Get correct paths and reset the support code library\r\n\t\tconst resolvedPaths = await resolvePaths(logger, this.cwd, messageData.coordinates, supportCodeCoordinates);\r\n\t\tconst { requirePaths, importPaths } = resolvedPaths;\r\n\t\tsupportCodeLibraryBuilder.reset(this.cwd, this.newId, {\r\n\t\t\trequirePaths,\r\n\t\t\trequireModules: supportCodeCoordinates.requireModules,\r\n\t\t\timportPaths,\r\n\t\t\tloaders: supportCodeCoordinates.loaders\r\n\t\t});\r\n\t\t// Load any require modules for CommonJS or loaders and imports for ESM\r\n\t\tsupportCodeCoordinates.requireModules.map(module => tryRequire(module));\r\n\t\trequirePaths.map(module => tryRequire(module));\r\n\t\tfor (const specifier of supportCodeCoordinates.loaders) {\r\n\t\t\tregister(specifier, pathToFileURL('./'));\r\n\t\t}\r\n\t\tfor (const path of supportCodeCoordinates.importPaths) {\r\n\t\t\tawait import(pathToFileURL(path).toString());\r\n\t\t}\r\n\t\t// Finalize the support code library with IDs passed in and\r\n\t\t// update entries in the library with info from our binding registry.\r\n\t\tthis.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds);\r\n\t\tthis.supportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(this.supportCodeLibrary);\r\n\r\n\t\t// Initialize a worker and run BeforeAll hooks\r\n\t\tthis.options = options;\r\n\t\tthis.worker = new Worker(this.id, this.eventBroadcaster, this.newId, this.options, this.supportCodeLibrary);\r\n\t\tawait this.worker.runBeforeAllHooks();\r\n\t\tthis.sendMessage({ type: 'READY' });\r\n\t}\r\n\r\n\t/**\r\n\t * Finialize the worker, which runs AfterAll hooks\r\n\t */\r\n\tasync finalize(): Promise<void> {\r\n\t\tawait this.worker.runAfterAllHooks();\r\n\t\tthis.exit(0);\r\n\t}\r\n\r\n\t/**\r\n\t * Interaction with the main process and child workers is done through IPC communications\r\n\t * This receives commands from the parent process and calls appropriate child operations.\r\n\t * @param command commands sent to this worker\r\n\t */\r\n\tasync receiveMessage(command: CoordinatorToWorkerCommand): Promise<void> {\r\n\t\tswitch (command.type) {\r\n\t\t\tcase 'INITIALIZE':\r\n\t\t\t\tawait this.initialize(command);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'RUN':\r\n\t\t\t\tawait this.runTestCase(command);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'FINALIZE':\r\n\t\t\t\tawait this.finalize();\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Run all test cases on the worker\r\n\t * @param command RunCommand\r\n\t */\r\n\tasync runTestCase(command: RunCommand): Promise<void> {\r\n\t\tconst success = await this.worker.runTestCase(command.assembledTestCase, command.failing);\r\n\t\tthis.sendMessage({\r\n\t\t\ttype: 'FINISHED',\r\n\t\t\tsuccess\r\n\t\t});\r\n\t}\r\n}\r\n"]}
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA2C;AAC3C,uCAAyC;AACzC,6CAAuC;AACvC,iDAA2D;AAC3D,sGAA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O,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC5G,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACb,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,OAAmC;QACvD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;YACtB,KAAK,YAAY;gBAChB,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC/B,MAAM;YACP,KAAK,KAAK;gBACT,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAChC,MAAM;YACP,KAAK,UAAU;gBACd,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACtB,MAAM;QACR,CAAC;IACF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,OAAmB;QACpC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1F,IAAI,CAAC,WAAW,CAAC;YAChB,IAAI,EAAE,UAAU;YAChB,OAAO;SACP,CAAC,CAAC;IACJ,CAAC;CACD;AA5HD,gDA4HC","sourcesContent":["import { EventEmitter } from 'node:events';\r\nimport { pathToFileURL } from 'node:url';\r\nimport { register } from 'node:module';\r\nimport { Envelope, IdGenerator } from '@cucumber/messages';\r\nimport supportCodeLibraryBuilder from '@cucumber/cucumber/lib/support_code_library_builder/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport tryRequire from '@cucumber/cucumber/lib/try_require';\r\nimport { Worker } from '../worker';\r\nimport { WorkerToCoordinatorEvent, RunCommand } from '@cucumber/cucumber/lib/runtime/parallel/types';\r\nimport logger from '../../utils/logger';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/paths';\r\nimport { BindingRegistry } from '../../bindings/binding-registry';\r\nimport { InitializeTsflowCommand, CoordinatorToWorkerCommand, TsFlowRuntimeOptions } from '../types';\r\nimport MessageCollector from '../message-collector';\r\n\r\nconst { uuid } = IdGenerator;\r\n\r\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void;\r\ntype IMessageSender = (command: WorkerToCoordinatorEvent) => void;\r\n\r\n/**\r\n * Represents a child process running in parallel executions\r\n */\r\nexport class ChildProcessWorker {\r\n\tprivate readonly cwd: string;\r\n\tprivate readonly exit: IExitFunction;\r\n\r\n\tprivate readonly id: string;\r\n\tprivate readonly eventBroadcaster: EventEmitter;\r\n\tprivate readonly newId: IdGenerator.NewId;\r\n\tprivate readonly sendMessage: IMessageSender;\r\n\tprivate options!: TsFlowRuntimeOptions;\r\n\tprivate supportCodeLibrary!: SupportCodeLibrary;\r\n\tprivate worker!: Worker;\r\n\r\n\tconstructor({\r\n\t\tcwd,\r\n\t\texit,\r\n\t\tid,\r\n\t\tsendMessage,\r\n\t\texperimentalDecorators\r\n\t}: {\r\n\t\tcwd: string;\r\n\t\texit: IExitFunction;\r\n\t\tid: string;\r\n\t\tsendMessage: IMessageSender;\r\n\t\texperimentalDecorators: boolean;\r\n\t}) {\r\n\t\tthis.id = id;\r\n\t\tthis.newId = uuid();\r\n\t\tthis.cwd = cwd;\r\n\t\tthis.exit = exit;\r\n\t\tthis.sendMessage = sendMessage;\r\n\t\tthis.eventBroadcaster = new EventEmitter();\r\n\r\n\t\t// initialize a message collector for this process to handle our\r\n\t\t// integration with event data\r\n\t\tglobal.messageCollector = new MessageCollector(this.eventBroadcaster);\r\n\r\n\t\t// initialize the global experimentalDecorators setting\r\n\t\tglobal.experimentalDecorators = experimentalDecorators;\r\n\r\n\t\t// pass any envelope messages up to the parent process to keep our main\r\n\t\t// message collector in sync with this one.\r\n\t\tthis.eventBroadcaster.on('envelope', (envelope: Envelope) => this.sendMessage({ type: 'ENVELOPE', envelope }));\r\n\t}\r\n\r\n\t/**\r\n\t * Initialize this child process worker\r\n\t */\r\n\tasync initialize({\r\n\t\tsupportCodeCoordinates,\r\n\t\tsupportCodeIds,\r\n\t\toptions,\r\n\t\tmessageData\r\n\t}: InitializeTsflowCommand): Promise<void> {\r\n\t\t// reset the message collector with message data passed in\r\n\t\tglobal.messageCollector.reset(messageData);\r\n\r\n\t\t// Get correct paths and reset the support code library\r\n\t\tconst resolvedPaths = await resolvePaths(logger, this.cwd, messageData.coordinates, supportCodeCoordinates);\r\n\t\tconst { requirePaths, importPaths } = resolvedPaths;\r\n\t\tsupportCodeLibraryBuilder.reset(this.cwd, this.newId, {\r\n\t\t\trequirePaths,\r\n\t\t\trequireModules: supportCodeCoordinates.requireModules,\r\n\t\t\timportPaths,\r\n\t\t\tloaders: supportCodeCoordinates.loaders\r\n\t\t});\r\n\t\t// Load any require modules for CommonJS or loaders and imports for ESM\r\n\t\tsupportCodeCoordinates.requireModules.map(module => tryRequire(module));\r\n\t\trequirePaths.map(module => tryRequire(module));\r\n\t\tfor (const specifier of supportCodeCoordinates.loaders) {\r\n\t\t\tregister(specifier, pathToFileURL('./'));\r\n\t\t}\r\n\t\tfor (const path of importPaths) {\r\n\t\t\tawait import(pathToFileURL(path).toString());\r\n\t\t}\r\n\t\t// Finalize the support code library with IDs passed in and\r\n\t\t// update entries in the library with info from our binding registry.\r\n\t\tthis.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds);\r\n\t\tthis.supportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(this.supportCodeLibrary);\r\n\r\n\t\t// Initialize a worker and run BeforeAll hooks\r\n\t\tthis.options = options;\r\n\t\tthis.worker = new Worker(this.id, this.eventBroadcaster, this.newId, this.options, this.supportCodeLibrary);\r\n\t\tawait this.worker.runBeforeAllHooks();\r\n\t\tthis.sendMessage({ type: 'READY' });\r\n\t}\r\n\r\n\t/**\r\n\t * Finialize the worker, which runs AfterAll hooks\r\n\t */\r\n\tasync finalize(): Promise<void> {\r\n\t\tawait this.worker.runAfterAllHooks();\r\n\t\tthis.exit(0);\r\n\t}\r\n\r\n\t/**\r\n\t * Interaction with the main process and child workers is done through IPC communications\r\n\t * This receives commands from the parent process and calls appropriate child operations.\r\n\t * @param command commands sent to this worker\r\n\t */\r\n\tasync receiveMessage(command: CoordinatorToWorkerCommand): Promise<void> {\r\n\t\tswitch (command.type) {\r\n\t\t\tcase 'INITIALIZE':\r\n\t\t\t\tawait this.initialize(command);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'RUN':\r\n\t\t\t\tawait this.runTestCase(command);\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'FINALIZE':\r\n\t\t\t\tawait this.finalize();\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Run all test cases on the worker\r\n\t * @param command RunCommand\r\n\t */\r\n\tasync runTestCase(command: RunCommand): Promise<void> {\r\n\t\tconst success = await this.worker.runTestCase(command.assembledTestCase, command.failing);\r\n\t\tthis.sendMessage({\r\n\t\t\ttype: 'FINISHED',\r\n\t\t\tsuccess\r\n\t\t});\r\n\t}\r\n}\r\n"]}
@@ -1,4 +1,5 @@
1
1
  import { INewTestCaseRunnerOptions } from '@cucumber/cucumber/lib/runtime/test_case_runner';
2
+ import { RunStepResult } from '@cucumber/cucumber/lib/runtime/step_runner';
2
3
  import * as messages from '@cucumber/messages';
3
4
  import { ITestCaseHookParameter } from '@cucumber/cucumber/lib/support_code_library_builder/types';
4
5
  import TestCaseHookDefinition from '@cucumber/cucumber/lib/models/test_case_hook_definition';
@@ -29,7 +30,7 @@ export default class TestCaseRunner {
29
30
  getBeforeStepHookDefinitions(): TestStepHookDefinition[];
30
31
  getAfterStepHookDefinitions(): TestStepHookDefinition[];
31
32
  getWorstStepResult(): messages.TestStepResult;
32
- invokeStep(step: messages.PickleStep, stepDefinition: IDefinition, hookParameter?: ITestCaseHookParameter): Promise<messages.TestStepResult>;
33
+ invokeStep(step: messages.PickleStep, stepDefinition: IDefinition, hookParameter?: ITestCaseHookParameter): Promise<RunStepResult>;
33
34
  isSkippingSteps(): boolean;
34
35
  shouldSkipHook(isBeforeHook: boolean): boolean;
35
36
  aroundTestStep(testStepId: string, runStepFn: () => Promise<messages.TestStepResult>): Promise<void>;
@@ -243,12 +243,13 @@ class TestCaseRunner {
243
243
  // initialize any context objects before hooks are executed
244
244
  const stepBinding = this.bindingRegistry.getStepBindingByCucumberKey(hookDefinition.options.cucumberKey);
245
245
  if (!stepBinding)
246
- throw (0, console_1.error)('Unable to find StepBinding!');
246
+ throw (0, console_1.error)('===268 test-case-runner.ts Unable to find StepBinding!');
247
247
  const scenarioContext = global.messageCollector.getHookScenarioContext(hookParameter);
248
248
  if (!scenarioContext)
249
249
  throw (0, console_1.error)('Unable to find the ManagedScenarioContext!');
250
250
  await this.initializeContext(stepBinding, scenarioContext);
251
- return await this.invokeStep(null, hookDefinition, hookParameter);
251
+ const { result } = await this.invokeStep(null, hookDefinition, hookParameter);
252
+ return result;
252
253
  }
253
254
  async runStepHooks(stepHooks, pickleStep, stepResult) {
254
255
  const stepHooksResult = [];
@@ -261,7 +262,8 @@ class TestCaseRunner {
261
262
  result: stepResult
262
263
  };
263
264
  for (const stepHookDefinition of stepHooks) {
264
- stepHooksResult.push(await this.invokeStep(null, stepHookDefinition, hookParameter));
265
+ const { result } = await this.invokeStep(null, stepHookDefinition, hookParameter);
266
+ stepHooksResult.push(result);
265
267
  }
266
268
  return stepHooksResult;
267
269
  }
@@ -292,7 +294,7 @@ class TestCaseRunner {
292
294
  // initialize any context objects before hooks are executed
293
295
  const stepBinding = this.bindingRegistry.getStepBindingByCucumberKey(stepDefinitions[0].options.cucumberKey);
294
296
  if (!stepBinding)
295
- throw (0, console_1.error)('Unable to find StepBinding!');
297
+ throw (0, console_1.error)('===323 test-case-runner.ts: Unable to find StepBinding!');
296
298
  const scenarioContext = global.messageCollector.getStepScenarioContext(stepBinding);
297
299
  if (!scenarioContext)
298
300
  throw (0, console_1.error)('Unable to find the ManagedScenarioContext!');
@@ -302,7 +304,8 @@ class TestCaseRunner {
302
304
  let stepResult;
303
305
  let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions(), pickleStep);
304
306
  if ((0, messages_1.getWorstTestStepResult)(stepResults).status !== messages.TestStepResultStatus.FAILED) {
305
- stepResult = await this.invokeStep(pickleStep, stepDefinitions[0]);
307
+ const { result } = await this.invokeStep(pickleStep, stepDefinitions[0]);
308
+ stepResult = result;
306
309
  stepResults.push(stepResult);
307
310
  }
308
311
  // run the after step hooks