@lynxwall/cucumber-tsflow 7.1.1 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +122 -53
  2. package/lib/api/convert-configuration.d.ts +7 -0
  3. package/lib/api/convert-configuration.js +65 -0
  4. package/lib/api/convert-configuration.js.map +1 -0
  5. package/lib/api/index.d.ts +1 -0
  6. package/lib/api/index.js +1 -0
  7. package/lib/api/index.js.map +1 -1
  8. package/lib/api/load-configuration.d.ts +3 -2
  9. package/lib/api/load-configuration.js +27 -11
  10. package/lib/api/load-configuration.js.map +1 -1
  11. package/lib/api/run-cucumber.d.ts +5 -1
  12. package/lib/api/run-cucumber.js +12 -0
  13. package/lib/api/run-cucumber.js.map +1 -1
  14. package/lib/api/wrapper.mjs +1 -0
  15. package/lib/bindings/binding-context.d.ts +15 -0
  16. package/lib/bindings/binding-context.js +32 -1
  17. package/lib/bindings/binding-context.js.map +1 -1
  18. package/lib/bindings/binding-decorator.js +57 -31
  19. package/lib/bindings/binding-decorator.js.map +1 -1
  20. package/lib/bindings/hook-decorators.js +43 -19
  21. package/lib/bindings/hook-decorators.js.map +1 -1
  22. package/lib/bindings/step-decorators.js +117 -51
  23. package/lib/bindings/step-decorators.js.map +1 -1
  24. package/lib/bindings/types.js.map +1 -1
  25. package/lib/cli/argv-parser.d.ts +1 -0
  26. package/lib/cli/argv-parser.js +1 -0
  27. package/lib/cli/argv-parser.js.map +1 -1
  28. package/lib/cli/index.js +1 -4
  29. package/lib/cli/index.js.map +1 -1
  30. package/lib/runtime/make-runtime.d.ts +3 -2
  31. package/lib/runtime/make-runtime.js.map +1 -1
  32. package/lib/runtime/message-collector.d.ts +1 -1
  33. package/lib/runtime/message-collector.js.map +1 -1
  34. package/lib/runtime/parallel/adapter.d.ts +3 -2
  35. package/lib/runtime/parallel/adapter.js +2 -1
  36. package/lib/runtime/parallel/adapter.js.map +1 -1
  37. package/lib/runtime/parallel/run-worker.js +3 -2
  38. package/lib/runtime/parallel/run-worker.js.map +1 -1
  39. package/lib/runtime/parallel/worker.d.ts +3 -2
  40. package/lib/runtime/parallel/worker.js +3 -1
  41. package/lib/runtime/parallel/worker.js.map +1 -1
  42. package/lib/runtime/{parallel/types.d.ts → types.d.ts} +12 -1
  43. package/lib/runtime/types.js.map +1 -0
  44. package/lib/transpilers/esbuild.js +18 -1
  45. package/lib/transpilers/esbuild.js.map +1 -1
  46. package/lib/transpilers/esnode.js +8 -0
  47. package/lib/transpilers/esnode.js.map +1 -0
  48. package/lib/transpilers/esvue.js +29 -0
  49. package/lib/transpilers/esvue.js.map +1 -0
  50. package/lib/{esnode.js → transpilers/tsnode-exp.js} +7 -5
  51. package/lib/transpilers/tsnode-exp.js.map +1 -0
  52. package/lib/{tsnode.js → transpilers/tsnode.js} +4 -1
  53. package/lib/transpilers/tsnode.js.map +1 -0
  54. package/lib/transpilers/tsvue-exp.d.ts +1 -0
  55. package/lib/{esvue.js → transpilers/tsvue-exp.js} +8 -6
  56. package/lib/transpilers/tsvue-exp.js.map +1 -0
  57. package/lib/transpilers/tsvue.d.ts +1 -0
  58. package/lib/{tsvue.js → transpilers/tsvue.js} +5 -2
  59. package/lib/transpilers/tsvue.js.map +1 -0
  60. package/lib/tsconfig.node.tsbuildinfo +1 -1
  61. package/lib/version.d.ts +1 -1
  62. package/lib/version.js +1 -1
  63. package/lib/version.js.map +1 -1
  64. package/package.json +12 -7
  65. package/lib/cli/load-configuration.d.ts +0 -21
  66. package/lib/cli/load-configuration.js +0 -124
  67. package/lib/cli/load-configuration.js.map +0 -1
  68. package/lib/cucumber/coordinator.d.ts +0 -15
  69. package/lib/cucumber/coordinator.js +0 -40
  70. package/lib/cucumber/coordinator.js.map +0 -1
  71. package/lib/cucumber/make-runtime.d.ts +0 -21
  72. package/lib/cucumber/make-runtime.js +0 -17
  73. package/lib/cucumber/make-runtime.js.map +0 -1
  74. package/lib/cucumber/managed-scenario-context.d.ts +0 -52
  75. package/lib/cucumber/managed-scenario-context.js +0 -149
  76. package/lib/cucumber/managed-scenario-context.js.map +0 -1
  77. package/lib/cucumber/message-collector.d.ts +0 -87
  78. package/lib/cucumber/message-collector.js +0 -280
  79. package/lib/cucumber/message-collector.js.map +0 -1
  80. package/lib/cucumber/parallel/adapter.d.ts +0 -46
  81. package/lib/cucumber/parallel/adapter.js +0 -156
  82. package/lib/cucumber/parallel/adapter.js.map +0 -1
  83. package/lib/cucumber/parallel/run-worker.d.ts +0 -1
  84. package/lib/cucumber/parallel/run-worker.js +0 -24
  85. package/lib/cucumber/parallel/run-worker.js.map +0 -1
  86. package/lib/cucumber/parallel/worker.d.ts +0 -26
  87. package/lib/cucumber/parallel/worker.js +0 -95
  88. package/lib/cucumber/parallel/worker.js.map +0 -1
  89. package/lib/cucumber/run-cucumber.d.ts +0 -16
  90. package/lib/cucumber/run-cucumber.js +0 -139
  91. package/lib/cucumber/run-cucumber.js.map +0 -1
  92. package/lib/cucumber/serial/adapter.d.ts +0 -12
  93. package/lib/cucumber/serial/adapter.js +0 -24
  94. package/lib/cucumber/serial/adapter.js.map +0 -1
  95. package/lib/cucumber/test-case-info.d.ts +0 -23
  96. package/lib/cucumber/test-case-info.js +0 -3
  97. package/lib/cucumber/test-case-info.js.map +0 -1
  98. package/lib/cucumber/test-case-runner.d.ts +0 -48
  99. package/lib/cucumber/test-case-runner.js +0 -359
  100. package/lib/cucumber/test-case-runner.js.map +0 -1
  101. package/lib/cucumber/utils.d.ts +0 -16
  102. package/lib/cucumber/utils.js +0 -78
  103. package/lib/cucumber/utils.js.map +0 -1
  104. package/lib/cucumber/worker.d.ts +0 -17
  105. package/lib/cucumber/worker.js +0 -57
  106. package/lib/cucumber/worker.js.map +0 -1
  107. package/lib/esnode.js.map +0 -1
  108. package/lib/esvue.js.map +0 -1
  109. package/lib/formatters/behave-json-formatter.d.ts +0 -49
  110. package/lib/formatters/behave-json-formatter.js +0 -85
  111. package/lib/formatters/behave-json-formatter.js.map +0 -1
  112. package/lib/formatters/junit-bamboo-formatter.d.ts +0 -17
  113. package/lib/formatters/junit-bamboo-formatter.js +0 -175
  114. package/lib/formatters/junit-bamboo-formatter.js.map +0 -1
  115. package/lib/formatters/tsflow-snippet-syntax.d.ts +0 -9
  116. package/lib/formatters/tsflow-snippet-syntax.js +0 -89
  117. package/lib/formatters/tsflow-snippet-syntax.js.map +0 -1
  118. package/lib/runtime/parallel/types.js.map +0 -1
  119. package/lib/tsnode.js.map +0 -1
  120. package/lib/tsvue.js.map +0 -1
  121. package/lib/types/parallel.d.ts +0 -11
  122. package/lib/types/parallel.js +0 -3
  123. package/lib/types/parallel.js.map +0 -1
  124. package/lib/types/scenario-context.d.ts +0 -16
  125. package/lib/types/scenario-context.js +0 -18
  126. package/lib/types/scenario-context.js.map +0 -1
  127. package/lib/types/scenario-info.d.ts +0 -16
  128. package/lib/types/scenario-info.js +0 -23
  129. package/lib/types/scenario-info.js.map +0 -1
  130. package/lib/types/step-binding-flags.d.ts +0 -53
  131. package/lib/types/step-binding-flags.js +0 -59
  132. package/lib/types/step-binding-flags.js.map +0 -1
  133. package/lib/types/step-binding.d.ts +0 -60
  134. package/lib/types/step-binding.js +0 -18
  135. package/lib/types/step-binding.js.map +0 -1
  136. package/lib/types/types.d.ts +0 -22
  137. package/lib/types/types.js +0 -3
  138. package/lib/types/types.js.map +0 -1
  139. /package/lib/runtime/{parallel/types.js → types.js} +0 -0
  140. /package/lib/{esnode.d.ts → transpilers/esnode.d.ts} +0 -0
  141. /package/lib/{esvue.d.ts → transpilers/esvue.d.ts} +0 -0
  142. /package/lib/{tsnode.d.ts → transpilers/tsnode-exp.d.ts} +0 -0
  143. /package/lib/{tsvue.d.ts → transpilers/tsnode.d.ts} +0 -0
@@ -2,6 +2,10 @@ import { Envelope } from '@cucumber/messages';
2
2
  import { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';
3
3
  import { IRunEnvironment } from '@cucumber/cucumber/lib/environment/index';
4
4
  import 'polyfill-symbol-metadata';
5
+ import { ITsFlowRunOptionsRuntime } from '../runtime/types';
6
+ export interface ITsFlowRunOptions extends IRunOptions {
7
+ runtime: ITsFlowRunOptionsRuntime;
8
+ }
5
9
  /**
6
10
  * Execute a Cucumber test run.
7
11
  *
@@ -13,4 +17,4 @@ import 'polyfill-symbol-metadata';
13
17
  * @param environment - Project environment.
14
18
  * @param onMessage - Callback fired each time Cucumber emits a message.
15
19
  */
16
- export declare function runCucumber(options: IRunOptions, environment?: IRunEnvironment, onMessage?: (message: Envelope) => void): Promise<IRunResult>;
20
+ export declare function runCucumber(options: ITsFlowRunOptions, environment?: IRunEnvironment, onMessage?: (message: Envelope) => void): Promise<IRunResult>;
@@ -18,6 +18,8 @@ const version_1 = require("../version");
18
18
  const plugins_1 = require("@cucumber/cucumber/lib/api/plugins");
19
19
  require("polyfill-symbol-metadata");
20
20
  const binding_registry_1 = require("../bindings/binding-registry");
21
+ const console_1 = require("console");
22
+ const ansis_1 = __importDefault(require("ansis"));
21
23
  /**
22
24
  * Execute a Cucumber test run.
23
25
  *
@@ -36,6 +38,16 @@ async function runCucumber(options, environment = {}, onMessage) {
36
38
  Working directory: ${cwd}
37
39
  Running from: ${__dirname}
38
40
  `);
41
+ const consoleLogger = new console_1.Console(environment.stdout, environment.stderr);
42
+ if (options.runtime.experimentalDecorators) {
43
+ consoleLogger.info(ansis_1.default.yellowBright('Using Experimental Decorators.'));
44
+ }
45
+ if (options.runtime.parallel > 0) {
46
+ consoleLogger.info(ansis_1.default.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\n`));
47
+ }
48
+ else {
49
+ consoleLogger.info(ansis_1.default.cyanBright('Running Cucumber-TsFlow in Serial mode.\n'));
50
+ }
39
51
  const newId = messages_1.IdGenerator.uuid();
40
52
  const supportCoordinates = 'originalCoordinates' in options.support
41
53
  ? options.support.originalCoordinates
@@ -1 +1 @@
1
- {"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run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,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC3B,CAAC;IACH,CAAC;IAED,IAAA,iCAAuB,EAAC;QACvB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/cli/helpers';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from '@cucumber/cucumber/lib/api/support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: IRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await getSupportCodeLibrary({\r\n\t\t\t\t\tlogger,\r\n\t\t\t\t\tcwd,\r\n\t\t\t\t\tnewId,\r\n\t\t\t\t\trequirePaths,\r\n\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\timportPaths,\r\n\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t});\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
1
+ {"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run-cucumber.ts"],"names":[],"mappings":";;;;;AAqCA,kCA4JC;AAjMD,iDAAuE;AACvE,mCAAsC;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B,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;QACnG,eAAe,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QAClF,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;IACzC,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAChC,MAAM,CAAC,KAAK,CAAC,mBAAmB,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC;QAC1B,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO;YACN,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC3B,CAAC;IACH,CAAC;IAED,IAAA,iCAAuB,EAAC;QACvB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/cli/helpers';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from '@cucumber/cucumber/lib/api/support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\nimport { ITsFlowRunOptionsRuntime } from '../runtime/types';\r\nimport { Console } from 'console';\r\nimport ansis from 'ansis';\r\n\r\nexport interface ITsFlowRunOptions extends IRunOptions {\r\n\truntime: ITsFlowRunOptionsRuntime;\r\n}\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: ITsFlowRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\tconst consoleLogger = new Console(environment.stdout as any, environment.stderr);\r\n\tif (options.runtime.experimentalDecorators) {\r\n\t\tconsoleLogger.info(ansis.yellowBright('Using Experimental Decorators.'));\r\n\t}\r\n\tif (options.runtime.parallel > 0) {\r\n\t\tconsoleLogger.info(\r\n\t\t\tansis.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\\n`)\r\n\t\t);\r\n\t} else {\r\n\t\tconsoleLogger.info(ansis.cyanBright('Running Cucumber-TsFlow in Serial mode.\\n'));\r\n\t}\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await getSupportCodeLibrary({\r\n\t\t\t\t\tlogger,\r\n\t\t\t\t\tcwd,\r\n\t\t\t\t\tnewId,\r\n\t\t\t\t\trequirePaths,\r\n\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\timportPaths,\r\n\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t});\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import api from './index.js';
2
2
 
3
+ export const convertConfiguration = api.convertConfiguration;
3
4
  export const loadConfiguration = api.loadConfiguration;
4
5
  export const loadSupport = api.loadSupport;
5
6
  export const loadSources = api.loadSources;
@@ -1,4 +1,19 @@
1
1
  import { StepBinding } from './step-binding';
2
+ /**
3
+ * Add a StepBinding to a local array for Experimental Decorators
4
+ *
5
+ * @param binding StepBinding to add
6
+ */
7
+ export declare const addStepBindingExp: (binding: StepBinding) => void;
8
+ /**
9
+ * Get all step bindings in the local array and then reset
10
+ * to an empty array if reset = true (default)
11
+ *
12
+ * @param context Current DecoratorContext
13
+ * @param reset Reset metadata on the context. Default=true
14
+ * @returns Array of StepBindings
15
+ */
16
+ export declare const getStepBindingsExp: (reset?: boolean) => StepBinding[];
2
17
  /**
3
18
  * Add a StepBinding to the DecoratorContext metadata
4
19
  *
@@ -1,6 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStepBindings = exports.addStepBinding = void 0;
3
+ exports.getStepBindings = exports.addStepBinding = exports.getStepBindingsExp = exports.addStepBindingExp = void 0;
4
+ let stepBindings = null;
5
+ /**
6
+ * Add a StepBinding to a local array for Experimental Decorators
7
+ *
8
+ * @param binding StepBinding to add
9
+ */
10
+ const addStepBindingExp = (binding) => {
11
+ if (!stepBindings)
12
+ stepBindings = new Array();
13
+ stepBindings.push(binding);
14
+ };
15
+ exports.addStepBindingExp = addStepBindingExp;
16
+ /**
17
+ * Get all step bindings in the local array and then reset
18
+ * to an empty array if reset = true (default)
19
+ *
20
+ * @param context Current DecoratorContext
21
+ * @param reset Reset metadata on the context. Default=true
22
+ * @returns Array of StepBindings
23
+ */
24
+ const getStepBindingsExp = (reset = true) => {
25
+ let bindings = [];
26
+ if (stepBindings && stepBindings.length > 0) {
27
+ bindings = [...stepBindings];
28
+ if (reset) {
29
+ stepBindings = new Array();
30
+ }
31
+ }
32
+ return bindings;
33
+ };
34
+ exports.getStepBindingsExp = getStepBindingsExp;
4
35
  /**
5
36
  * Add a StepBinding to the DecoratorContext metadata
6
37
  *
@@ -1 +1 @@
1
- {"version":3,"file":"binding-context.js","sourceRoot":"","sources":["../../src/bindings/binding-context.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAAC,OAAyB,EAAE,OAAoB,EAAQ,EAAE;IACvF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY;QAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;IAC5F,OAAO,CAAC,QAAQ,CAAC,YAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF;;;;;;;GAOG;AACI,MAAM,eAAe,GAAG,CAAC,OAAyB,EAAE,QAAiB,IAAI,EAAiB,EAAE;IAClG,IAAI,QAAQ,GAAkB,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAkC,CAAC;IACzE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,QAAQ,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B","sourcesContent":["import { StepBinding } from './step-binding';\r\n\r\n/**\r\n * Add a StepBinding to the DecoratorContext metadata\r\n *\r\n * @param context Current DecoratorContext\r\n * @param binding StepBinding to add\r\n */\r\nexport const addStepBinding = (context: DecoratorContext, binding: StepBinding): void => {\r\n\tif (!context.metadata.stepBindings) context.metadata.stepBindings = new Array<StepBinding>();\r\n\t(context.metadata.stepBindings as Array<StepBinding>).push(binding);\r\n};\r\n\r\n/**\r\n * Get all step bindings in DecoratorContext metadata and then reset\r\n * stepBindings in the metadata to an empty array if reset = true (default)\r\n *\r\n * @param context Current DecoratorContext\r\n * @param reset Reset metadata on the context. Default=true\r\n * @returns Array of StepBindings\r\n */\r\nexport const getStepBindings = (context: DecoratorContext, reset: boolean = true): StepBinding[] => {\r\n\tlet bindings: StepBinding[] = [];\r\n\tconst stepBindings = context.metadata.stepBindings as Array<StepBinding>;\r\n\tif (stepBindings && stepBindings.length > 0) {\r\n\t\tbindings = [...stepBindings];\r\n\t\tif (reset) {\r\n\t\t\tcontext.metadata.stepBindings = new Array<StepBinding>();\r\n\t\t}\r\n\t}\r\n\treturn bindings;\r\n};\r\n"]}
1
+ {"version":3,"file":"binding-context.js","sourceRoot":"","sources":["../../src/bindings/binding-context.ts"],"names":[],"mappings":";;;AAEA,IAAI,YAAY,GAAuB,IAAI,CAAC;AAE5C;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,OAAoB,EAAQ,EAAE;IAC/D,IAAI,CAAC,YAAY;QAAE,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;IAC3D,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEF;;;;;;;GAOG;AACI,MAAM,kBAAkB,GAAG,CAAC,QAAiB,IAAI,EAAiB,EAAE;IAC1E,IAAI,QAAQ,GAAkB,EAAE,CAAC;IACjC,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,QAAQ,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,CAAC;YACX,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B;AAEF;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAAC,OAAyB,EAAE,OAAoB,EAAQ,EAAE;IACvF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY;QAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;IAC5F,OAAO,CAAC,QAAQ,CAAC,YAAmC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrE,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF;;;;;;;GAOG;AACI,MAAM,eAAe,GAAG,CAAC,OAAyB,EAAE,QAAiB,IAAI,EAAiB,EAAE;IAClG,IAAI,QAAQ,GAAkB,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAkC,CAAC;IACzE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7C,QAAQ,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,QAAQ,CAAC,YAAY,GAAG,IAAI,KAAK,EAAe,CAAC;QAC1D,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B","sourcesContent":["import { StepBinding } from './step-binding';\r\n\r\nlet stepBindings: Array<StepBinding> = null;\r\n\r\n/**\r\n * Add a StepBinding to a local array for Experimental Decorators\r\n *\r\n * @param binding StepBinding to add\r\n */\r\nexport const addStepBindingExp = (binding: StepBinding): void => {\r\n\tif (!stepBindings) stepBindings = new Array<StepBinding>();\r\n\tstepBindings.push(binding);\r\n};\r\n\r\n/**\r\n * Get all step bindings in the local array and then reset\r\n * to an empty array if reset = true (default)\r\n *\r\n * @param context Current DecoratorContext\r\n * @param reset Reset metadata on the context. Default=true\r\n * @returns Array of StepBindings\r\n */\r\nexport const getStepBindingsExp = (reset: boolean = true): StepBinding[] => {\r\n\tlet bindings: StepBinding[] = [];\r\n\tif (stepBindings && stepBindings.length > 0) {\r\n\t\tbindings = [...stepBindings];\r\n\t\tif (reset) {\r\n\t\t\tstepBindings = new Array<StepBinding>();\r\n\t\t}\r\n\t}\r\n\treturn bindings;\r\n};\r\n\r\n/**\r\n * Add a StepBinding to the DecoratorContext metadata\r\n *\r\n * @param context Current DecoratorContext\r\n * @param binding StepBinding to add\r\n */\r\nexport const addStepBinding = (context: DecoratorContext, binding: StepBinding): void => {\r\n\tif (!context.metadata.stepBindings) context.metadata.stepBindings = new Array<StepBinding>();\r\n\t(context.metadata.stepBindings as Array<StepBinding>).push(binding);\r\n};\r\n\r\n/**\r\n * Get all step bindings in DecoratorContext metadata and then reset\r\n * stepBindings in the metadata to an empty array if reset = true (default)\r\n *\r\n * @param context Current DecoratorContext\r\n * @param reset Reset metadata on the context. Default=true\r\n * @returns Array of StepBindings\r\n */\r\nexport const getStepBindings = (context: DecoratorContext, reset: boolean = true): StepBinding[] => {\r\n\tlet bindings: StepBinding[] = [];\r\n\tconst stepBindings = context.metadata.stepBindings as Array<StepBinding>;\r\n\tif (stepBindings && stepBindings.length > 0) {\r\n\t\tbindings = [...stepBindings];\r\n\t\tif (reset) {\r\n\t\t\tcontext.metadata.stepBindings = new Array<StepBinding>();\r\n\t\t}\r\n\t}\r\n\treturn bindings;\r\n};\r\n"]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.binding = binding;
7
7
  const cucumber_1 = require("@cucumber/cucumber");
8
8
  const binding_context_1 = require("./binding-context");
9
- const index_1 = __importDefault(require("@cucumber/cucumber/lib/support_code_library_builder/index"));
10
9
  const binding_registry_1 = require("./binding-registry");
11
10
  const step_binding_1 = require("./step-binding");
12
11
  const cucumber_2 = require("@cucumber/cucumber");
@@ -29,36 +28,42 @@ const stepPatternRegistrations = new Map();
29
28
  * An instance of the decorated class will be created for each scenario.
30
29
  */
31
30
  function binding(requiredContextTypes) {
32
- return function classDecorator(target, context) {
33
- const bindingRegistry = binding_registry_1.BindingRegistry.instance;
34
- bindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);
35
- const lib = index_1.default;
36
- defineParameters();
37
- // the class decorator is called last when decorators on a type are initialized. All other decorators
38
- // are added to DecoratorContext.metadata before this is called.
39
- // This will get all those bindings and then clear metadata for the next type that's loaded.
40
- const allBindings = (0, binding_context_1.getStepBindings)(context);
41
- allBindings.forEach(stepBinding => {
42
- // Set the class prototype and then register the binding with the prototype
43
- stepBinding.classPrototype = target.prototype;
44
- bindingRegistry.registerStepBinding(stepBinding);
45
- if (stepBinding.bindingType & step_binding_1.StepBindingFlags.StepDefinitions) {
46
- let stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());
47
- if (stepBindingFlags === undefined) {
48
- stepBindingFlags = step_binding_1.StepBindingFlags.none;
49
- }
50
- if (stepBindingFlags & stepBinding.bindingType) {
51
- return;
52
- }
53
- bindStepDefinition(stepBinding);
54
- stepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);
55
- }
56
- else if (stepBinding.bindingType & step_binding_1.StepBindingFlags.Hooks) {
57
- bindHook(stepBinding);
58
- }
59
- });
60
- return target;
61
- };
31
+ if (global.experimentalDecorators) {
32
+ return (target) => {
33
+ const bindingRegistry = binding_registry_1.BindingRegistry.instance;
34
+ bindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);
35
+ defineParameters();
36
+ // the class decorator is called last when decorators on a type are initialized. All other decorators
37
+ // are added to DecoratorContext.metadata before this is called.
38
+ // This will get all those bindings and then clear metadata for the next type that's loaded.
39
+ const allBindings = (0, binding_context_1.getStepBindingsExp)();
40
+ allBindings.forEach(stepBinding => {
41
+ // register the binding
42
+ bindingRegistry.registerStepBinding(stepBinding);
43
+ // add the step binding to the binding registry
44
+ addStepBinding(stepBinding);
45
+ });
46
+ };
47
+ }
48
+ else {
49
+ return function classDecorator(target, context) {
50
+ const bindingRegistry = binding_registry_1.BindingRegistry.instance;
51
+ bindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);
52
+ defineParameters();
53
+ // the class decorator is called last when decorators on a type are initialized. All other decorators
54
+ // are added to DecoratorContext.metadata before this is called.
55
+ // This will get all those bindings and then clear metadata for the next type that's loaded.
56
+ const allBindings = (0, binding_context_1.getStepBindings)(context);
57
+ allBindings.forEach(stepBinding => {
58
+ // Set the class prototype and then register the binding with the prototype
59
+ stepBinding.classPrototype = target.prototype;
60
+ bindingRegistry.registerStepBinding(stepBinding);
61
+ // add the step binding to the binding registry
62
+ addStepBinding(stepBinding);
63
+ });
64
+ return target;
65
+ };
66
+ }
62
67
  }
63
68
  /**
64
69
  * Called only once to register new parameters. This has to be
@@ -73,6 +78,27 @@ const defineParameters = underscore_1.default.once(() => {
73
78
  transformer: s => (s === 'true' ? true : false)
74
79
  });
75
80
  });
81
+ /**
82
+ * Common helper used to add StepBindings to the binding registry
83
+ * @param stepBinding
84
+ * @returns
85
+ */
86
+ function addStepBinding(stepBinding) {
87
+ if (stepBinding.bindingType & step_binding_1.StepBindingFlags.StepDefinitions) {
88
+ let stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());
89
+ if (stepBindingFlags === undefined) {
90
+ stepBindingFlags = step_binding_1.StepBindingFlags.none;
91
+ }
92
+ if (stepBindingFlags & stepBinding.bindingType) {
93
+ return;
94
+ }
95
+ bindStepDefinition(stepBinding);
96
+ stepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);
97
+ }
98
+ else if (stepBinding.bindingType & step_binding_1.StepBindingFlags.Hooks) {
99
+ bindHook(stepBinding);
100
+ }
101
+ }
76
102
  /**
77
103
  * Binds a step definition to Cucumber.
78
104
  *
@@ -1 +1 @@
1
- {"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../../src/bindings/binding-decorator.ts"],"names":[],"mappings":";;;;;AA0CA,0BAgCC;AA1ED,iDAW4B;AAC5B,uDAAoD;AACpD,sGAAkG;AAClG,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,OAAO,SAAS,cAAc,CAAC,MAAgB,EAAE,OAA8B;QAC9E,MAAM,eAAe,GAAG,kCAAe,CAAC,QAAQ,CAAC;QACjD,eAAe,CAAC,4BAA4B,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACrF,M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K,+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 } from './binding-context';\r\nimport supportCodeLibraryBuilder from '@cucumber/cucumber/lib/support_code_library_builder/index';\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\treturn function classDecorator(target: Function, context: ClassDecoratorContext) {\r\n\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\t\tconst lib = supportCodeLibraryBuilder;\r\n\t\tdefineParameters();\r\n\r\n\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\tconst allBindings: StepBinding[] = getStepBindings(context);\r\n\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t// Set the class prototype and then register the binding with the prototype\r\n\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\tif (stepBinding.bindingType & StepBindingFlags.StepDefinitions) {\r\n\t\t\t\tlet stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());\r\n\t\t\t\tif (stepBindingFlags === undefined) {\r\n\t\t\t\t\tstepBindingFlags = StepBindingFlags.none;\r\n\t\t\t\t}\r\n\t\t\t\tif (stepBindingFlags & stepBinding.bindingType) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tbindStepDefinition(stepBinding);\r\n\t\t\t\tstepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);\r\n\t\t\t} else if (stepBinding.bindingType & StepBindingFlags.Hooks) {\r\n\t\t\t\tbindHook(stepBinding);\r\n\t\t\t}\r\n\t\t});\r\n\t\treturn target;\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 * 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, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]}
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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U,EAAC,OAAO,EAAE,YAAY,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, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]}
@@ -81,25 +81,49 @@ function checkTag(tag) {
81
81
  return tag;
82
82
  }
83
83
  function createDecoratorFactory(flag, callSite, tag, timeout) {
84
- return function hookDecorator(target, context) {
85
- const stepBinding = {
86
- stepPattern: '',
87
- bindingType: flag,
88
- classPrototype: undefined,
89
- classPropertyKey: context.name,
90
- stepFunction: target,
91
- stepIsStatic: context.static,
92
- stepArgsLength: target.length,
93
- tags: tag,
94
- timeout: timeout,
95
- callsite: callSite,
96
- cucumberKey: (0, short_uuid_1.default)().new()
84
+ if (global.experimentalDecorators) {
85
+ return (target, propertyKey, descriptor) => {
86
+ const stepBinding = {
87
+ stepPattern: '',
88
+ bindingType: flag,
89
+ classPrototype: target,
90
+ classPropertyKey: propertyKey,
91
+ stepFunction: target[propertyKey],
92
+ stepIsStatic: false,
93
+ stepArgsLength: target[propertyKey].length,
94
+ tags: tag,
95
+ timeout: timeout,
96
+ callsite: callSite,
97
+ cucumberKey: (0, short_uuid_1.default)().new()
98
+ };
99
+ if (tag) {
100
+ stepBinding.tags = checkTag(tag);
101
+ }
102
+ (0, binding_context_1.addStepBindingExp)(stepBinding);
103
+ return descriptor;
97
104
  };
98
- if (tag) {
99
- stepBinding.tags = checkTag(tag);
100
- }
101
- (0, binding_context_1.addStepBinding)(context, stepBinding);
102
- return;
103
- };
105
+ }
106
+ else {
107
+ return function hookDecorator(target, context) {
108
+ const stepBinding = {
109
+ stepPattern: '',
110
+ bindingType: flag,
111
+ classPrototype: undefined,
112
+ classPropertyKey: context.name,
113
+ stepFunction: target,
114
+ stepIsStatic: context.static,
115
+ stepArgsLength: target.length,
116
+ tags: tag,
117
+ timeout: timeout,
118
+ callsite: callSite,
119
+ cucumberKey: (0, short_uuid_1.default)().new()
120
+ };
121
+ if (tag) {
122
+ stepBinding.tags = checkTag(tag);
123
+ }
124
+ (0, binding_context_1.addStepBinding)(context, stepBinding);
125
+ return;
126
+ };
127
+ }
104
128
  }
105
129
  //# sourceMappingURL=hook-decorators.js.map
@@ -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,uDAAmD;AAEnD;;;;;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;AACD;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,IAAa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binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding } 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\treturn function hookDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\tconst stepBinding: StepBinding = {\r\n\t\t\tstepPattern: '',\r\n\t\t\tbindingType: flag,\r\n\t\t\tclassPrototype: undefined,\r\n\t\t\tclassPropertyKey: context.name,\r\n\t\t\tstepFunction: target,\r\n\t\t\tstepIsStatic: context.static,\r\n\t\t\tstepArgsLength: target.length,\r\n\t\t\ttags: tag,\r\n\t\t\ttimeout: timeout,\r\n\t\t\tcallsite: callSite,\r\n\t\t\tcucumberKey: shortUuid().new()\r\n\t\t};\r\n\r\n\t\tif (tag) {\r\n\t\t\tstepBinding.tags = checkTag(tag);\r\n\t\t}\r\n\t\taddStepBinding(context, stepBinding);\r\n\r\n\t\treturn;\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,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,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AE,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"]}