{"_id":"55a4995ee10ba50d00b40ba1","project":"559b65bd8b04e90d00702d54","__v":8,"category":{"_id":"55a4971be6c2470d002a6483","pages":["55a4995ee10ba50d00b40ba1","55a49c75e6c2470d002a6489","55a4a08de10ba50d00b40baf","55a4a0a5dad9d00d0071fca7","55a4a151dad9d00d0071fcab","55a4a211e6c2470d002a6495","55a4a72ae10ba50d00b40bc1","56043fdce5102a0d0070f937","566ca739f0a5dc0d009acbc3"],"project":"559b65bd8b04e90d00702d54","version":"559b65bd8b04e90d00702d57","__v":9,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-14T04:59:07.396Z","from_sync":false,"order":3,"slug":"must-know","title":"Must Know"},"user":"559b658d8b04e90d00702d52","parentDoc":null,"version":{"_id":"559b65bd8b04e90d00702d57","project":"559b65bd8b04e90d00702d54","__v":6,"createdAt":"2015-07-07T05:38:05.890Z","releaseDate":"2015-07-07T05:38:05.890Z","categories":["559b65be8b04e90d00702d58","55a46e7468c7e20d0036d4d1","55a4971be6c2470d002a6483","55a4a690e10ba50d00b40bba","55a4bcf31a5f991700a94066","56cf5c8d336aa60b0086a40d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["55c74cf2476be90d0050086f"],"next":{"pages":[],"description":""},"createdAt":"2015-07-14T05:08:46.507Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Cucumber is a framework for defining behavior using a language called [Gherkin](https://cucumber.io/docs/reference#gherkin). The Gherkin syntax uses a combination of keywords and natural language.\n\nFeature files with a `.feature` extension are parsed with the *Gherkin* syntax. Consider this feature file:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Feature: One-line description of the feature\\n\\n\\tAnything can be used here to provide context for this specification. \\n  You may want to use the story format below.\\n\\n  As an <actor>\\n  I want <feature>\\n  So that <benefit>\\n\\n  Background: The background is optional\\n    Given something that happens before every scenario\\n    And something else that happens before every scenario\\n\\n  Scenario: One-line description of the scenario\\n    Given some pre-condition with a parameter \\\"myParam\\\"\\n    And another pre-condition\\n    When an event is triggered\\n    Then an expected result happens\\n    But an unexpected result does not happen\",\n      \"language\": \"yaml\"\n    }\n  ]\n}\n[/block]\nSome things to note about this file:\n\n* It is the specification of a single feature for the application / system\n* A feature can have freeform context before scenarios are defined. \n* A feature has many scenarios. \n* Each scenario is a unique flow within the feature\n* A scenario has many steps.\n* A step starts with a keyword and contains freeform text\n* A feature may contain an optional background which also contains steps\n\nSteps are the bridge between the feature and the automation layer. They are automated using step definition files. The step definitions can be defined either in javascript or coffee using the `--coffee` switch. Here is an example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"this.Given(/^some pre-condition with a parameter \\\"([^\\\"]*)\\\"$/, function (arg1) {\\n  // Write the automation code here\\n  pending();\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nYou will notice the step definition above uses regex to match the step in the feature file. The regex can also extract parameters from the freeform text. The Gherkin syntax also supports tables and multi-line strings amongst other constructs.\n\nThis is a very brief overview of Cucumber and the Gherkin syntax. Be sure to check out the further reading section for additional learning resources on the wonderful subject of Behavior Driven Development (BDD).\n\nSee the official documentation here:\n* [Cucumber-js repository](https://github.com/cucumber/cucumber-js) \n* [Cucumber Website](https://cucumber.io/)\n\n---\n\n<a href=\"http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch\"><img src=\"https://files.readme.io/764e495-qualityfasterbook-commas.small.png\" width=\"200\" align=\"right\" /></a>\n##Learn the Fundamentals of Testing, Specifications and Become a Chimp Ninja!\n[Checkout our new book](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch) where you can learn how to can use Chimp across the Full Stack from React to Node.JS, Mocha, Meteor and more.\n\n\n**[Quality, Faster.](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch)** By Sam Hatoum, creator of Chimp.","excerpt":"Specifications Repository & Automation Layer","slug":"cucumberjs","type":"basic","title":"Cucumber.js"}

Cucumber.js

Specifications Repository & Automation Layer

Cucumber is a framework for defining behavior using a language called [Gherkin](https://cucumber.io/docs/reference#gherkin). The Gherkin syntax uses a combination of keywords and natural language. Feature files with a `.feature` extension are parsed with the *Gherkin* syntax. Consider this feature file: [block:code] { "codes": [ { "code": "Feature: One-line description of the feature\n\n\tAnything can be used here to provide context for this specification. \n You may want to use the story format below.\n\n As an <actor>\n I want <feature>\n So that <benefit>\n\n Background: The background is optional\n Given something that happens before every scenario\n And something else that happens before every scenario\n\n Scenario: One-line description of the scenario\n Given some pre-condition with a parameter \"myParam\"\n And another pre-condition\n When an event is triggered\n Then an expected result happens\n But an unexpected result does not happen", "language": "yaml" } ] } [/block] Some things to note about this file: * It is the specification of a single feature for the application / system * A feature can have freeform context before scenarios are defined. * A feature has many scenarios. * Each scenario is a unique flow within the feature * A scenario has many steps. * A step starts with a keyword and contains freeform text * A feature may contain an optional background which also contains steps Steps are the bridge between the feature and the automation layer. They are automated using step definition files. The step definitions can be defined either in javascript or coffee using the `--coffee` switch. Here is an example: [block:code] { "codes": [ { "code": "this.Given(/^some pre-condition with a parameter \"([^\"]*)\"$/, function (arg1) {\n // Write the automation code here\n pending();\n});", "language": "javascript" } ] } [/block] You will notice the step definition above uses regex to match the step in the feature file. The regex can also extract parameters from the freeform text. The Gherkin syntax also supports tables and multi-line strings amongst other constructs. This is a very brief overview of Cucumber and the Gherkin syntax. Be sure to check out the further reading section for additional learning resources on the wonderful subject of Behavior Driven Development (BDD). See the official documentation here: * [Cucumber-js repository](https://github.com/cucumber/cucumber-js) * [Cucumber Website](https://cucumber.io/) --- <a href="http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch"><img src="https://files.readme.io/764e495-qualityfasterbook-commas.small.png" width="200" align="right" /></a> ##Learn the Fundamentals of Testing, Specifications and Become a Chimp Ninja! [Checkout our new book](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch) where you can learn how to can use Chimp across the Full Stack from React to Node.JS, Mocha, Meteor and more. **[Quality, Faster.](http://quality.xolv.io/?utm_source=XolvOSS&utm_medium=OSSDocs&utm_content=ChimpRM-Footer&utm_campaign=QFLaunch)** By Sam Hatoum, creator of Chimp.