{"_id":"@basementuniverse/cucumber-tsflow","_rev":"1-3cfd37e08d12fbdf2f2e2e893639869f","name":"@basementuniverse/cucumber-tsflow","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@basementuniverse/cucumber-tsflow","description":"Provides 'specflow' like bindings for CucumberJS 7.0.0+ in TypeScript 1.7+, with additional hooks","version":"4.0.0","author":{"name":"Tim Roberts","email":"tim@timjroberts.com"},"license":"MIT","main":"./dist","keywords":["testing","bdd","cucumber","gherkin","tests","typescript","specflow"],"repository":{"type":"git","url":"git+https://github.com/basementuniverse/cucumber-tsflow.git"},"dependencies":{"callsites":"^3.1.0","log4js":"^6.3.0","source-map-support":"^0.5.19","underscore":"^1.8.3"},"gitHead":"79b4f78b68a92ece0e44334e06b2bab671b94bdb","bugs":{"url":"https://github.com/basementuniverse/cucumber-tsflow/issues"},"homepage":"https://github.com/basementuniverse/cucumber-tsflow#readme","_id":"@basementuniverse/cucumber-tsflow@4.0.0","_nodeVersion":"12.22.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-pwNvIzvqBLQvRj32mJKRKcfZHgvyils21oJ4YXq64INLmJXHFiOEZzoqe/mP0aMvkDgM+MinAp4gB3xRryNmrw==","shasum":"5ac9f76966e0e2896ee3bc422c74c433c8c060ee","tarball":"https://registry.npmjs.org/@basementuniverse/cucumber-tsflow/-/cucumber-tsflow-4.0.0.tgz","fileCount":55,"unpackedSize":79783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgisngCRA9TVsSAnZWagAAnQUP/0aiS+P+6ux6OCwiakZp\nMSZY5cxYL1P6kOhpRKgzR74SSs8w0nMkEUxCG/idT07eHLlESDhnfWwk2VI/\np4q38kMoYQoZ79Ef0vro3Y8oHaXlfPINO1qWIaZbocRvVpjfNdlFl4BQxupb\n8GDU8EXraywGH7MI4av7WsrOh6BqHAIdu9iwkNCQ9m4eXHxqE+iHGCkWsVMu\n9pl0nI/C/M4SpCcqRaR/Y7kYP7sTy6a4YFnAPFpzlsHKneQl4+y2s7kkwWrW\nR5kUakqEkDpQM8IxDupuEKqhRwuLCOnQlQuq/PfnD2maB6o2Fgr9NJ5GSfW9\nXchOyMuiYBjObcl3+pLhPImgoq0KKyDih5UTlIKSQPS6buBonLV6ripWyOUQ\npcEzNRZHY6VgvNEFYBNfdrSae7t8AyVDiaykKwcN1Bp4I64Kz3tP0Xr6JXdj\n5HVGdvud+MUxn095qLDyvm44GrOWxJ+o3K+iRjzcoVWR7FdvRgAzDElCARkr\nVbWw4lvCt0K6x5xj4Y1jxPXR1FgzU1eBsiAKuA/MDA6sv7Dcfsq/uvWEYcEL\n4QPJtII6+17xvAbkbboJ2PJoq51qw/C+9zKWkgcSdhEnOawivdFZCs0cqGcU\nZ2QB5w042BGO5sYk23T5nghU4ywaVf61x5xBnsWOvIyYUU3Hai/vF0sO1iOP\nUjLd\r\n=5RgQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDOhnVJvKQYPGOEteCy7WhO5UMUp2BXkjYed2d9QxPHzAiEAiawwp8T0IZV6wbYDcz6RJkUm+gYXvg/EUPkGRL2JiR8="}]},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"directories":{},"maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cucumber-tsflow_4.0.0_1619708384350_0.05877673419192053"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-29T14:59:44.310Z","4.0.0":"2021-04-29T14:59:44.555Z","modified":"2022-04-04T17:46:21.447Z"},"maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"description":"Provides 'specflow' like bindings for CucumberJS 7.0.0+ in TypeScript 1.7+, with additional hooks","homepage":"https://github.com/basementuniverse/cucumber-tsflow#readme","keywords":["testing","bdd","cucumber","gherkin","tests","typescript","specflow"],"repository":{"type":"git","url":"git+https://github.com/basementuniverse/cucumber-tsflow.git"},"author":{"name":"Tim Roberts","email":"tim@timjroberts.com"},"bugs":{"url":"https://github.com/basementuniverse/cucumber-tsflow/issues"},"license":"MIT","readme":"# cucumber-tsflow\n\nProvides 'specflow' like bindings for CucumberJS in TypeScript 1.7+.\n\n### Fork description\n\nThis is a detached fork of https://github.com/timjroberts/cucumber-js-tsflow, including only the `./cucumber-tsflow` directory. It has had the https://github.com/wudong/cucumber-js-tsflow/tree/before_after_all_hooks branch merged into it, which adds support for `beforeAll` and `afterAll` hooks.\n\n### Bindings\n\nBindings provide the automation that connects a specification step in a Gherkin feature file to some code that\nexecutes for that step. When using Cucumber with TypeScript you can define this automation using a 'binding' class:\n\n```javascript\nimport { binding } from \"cucumber-tsflow\";\n\n@binding()\nclass MySteps {\n    ...\n}\n\nexport = MySteps;\n```\n\n*Note*: You must use the `export = <type>;` because Cucumber expects exports in this manner.\n\n### Step Definitions\n\nStep definitions can be bound to automation code in a 'binding' class by implementing a public function that is\nbound with a 'given', 'when' or 'then' binding decorator:\n\n```javascript\nimport { binding, given, when then } from \"cucumber-tsflow\";\n\n@binding()\nclass MySteps {\n    ...\n    @given(/I perform a search using the value \"([^\"]*)\"/)\n    public givenAValueBasedSearch(searchValue: string): void {\n        ...\n    }\n    ...\n}\n\nexport = MySteps;\n```\nThe function follows the same requirements of functions you would normally supply to Cucumber which means that the\nfunctions may be synchronous by returning nothing, use the callback, or return a `Promise<T>`. Additionally, the\nfunction may also be `async` following the TypeScript async semantics.\n\nStep definitions may also be scoped at a tag level by supplying an optional tag name when using the binding\ndecorators:\n\n```javascript\n@given(/I perform a search using the value \"([^\"]*)\"/)\npublic givenAValueBasedSearch(searchValue: string): void {\n    ...\n    // The default step definition\n    ...\n}\n\n@given(/I perform a search using the value \"([^\"]*)\"/, \"tagName\")\npublic givenAValueBasedSearch(searchValue: string): void {\n    ...\n    // The step definition that will execute if the feature or\n    // scenario has the @tagName defined on it\n    ...\n}\n```\n\n#### Hooks\n\nHooks can be used to perform additional automation on specific events such as before or after scenario execution.\nHooks can be restricted to run for only features or scenarios with a specific tag:\n\n```javascript\nimport { binding, before, after } from \"cucumber-tsflow\";\n\n@binding()\nclass MySteps {\n    ...\n    @before()\n    public beforeEachScenario(): void {\n        // This will be called before each scenario\n        ...\n    }\n    ...\n\n    @before(\"requireTempDir\")\n    public async beforeEachScenarioRequiringTempDirectory(): Promise<void> {\n        // This will be called before each scenario tagged with 'requireTempDir', or before every scenario in features tagged with 'requireTempDir'\n        let tempDirInfo = await this.createTempDirectory();\n\n        ...\n    }\n\n    @after()\n    public afterEachScenario(): void {\n        // This will be called after each scenario\n        ...\n    }\n\n    @after(\"requireTempDir\")\n    public afterEachScenarioRequiringTempDirectory(): void {\n        // This will be called after each scenario tagged with 'requireTempDir`, or after every scenario in features tagged with 'requireTempDir'\n        ...\n    }\n    \n    @beforeAll()\n    public static beforeAllScenarios(): void {\n        // This will be called before the first scenario\n        // It must be a static method\n        ...\n    }\n    \n    @afterAll()\n    public static afterAllScenarios(): void {\n        // This will be called after the last scenario\n        // It must be a static method\n        ...\n    }\n}\n\nexport = MySteps;\n```\n\n### Sharing Data between Bindings\n\n#### Context Injection\n\nLike 'specflow', cucumber-tsflow supports a simple dependency injection framework that will instantitate and inject\nclass instances into 'binding' classes for each execuing scenario.\n\nTo use context injection:\n\n* Create simple classes representing the shared data (they *must* have default constructors)\n* Define a constructor on the 'binding' classes that will require the shared data that accepts the context objects\nas parameters\n* Update the `@binding()` decorator to indicate the types of context objects that are required by the 'binding'\nclass\n\n```javascript\nimport { binding, before, after } from \"cucumber-tsflow\";\nimport { Workspace } from \"./Workspace\";\n\n@binding([Workspace])\nclass MySteps {\n    constructor(protected workspace: Workspace)\n    { }\n\n    @before(\"requireTempDir\")\n    public async beforeAllScenariosRequiringTempDirectory(): Promise<void> {\n        let tempDirInfo = await this.createTemporaryDirectory();\n\n        this.workspace.updateFolder(tempDirInfo);\n    }\n}\n\nexport = MySteps;\n```\n\n","readmeFilename":"README.md"}