cucumber.js: cuke up your javascript!
DESCRIPTION
We're now living the golden age of JavaScript. An increasingly number of people are seeing it as a complete language. Therefore, agile development practices are now being adapted and applied to JavaScript code production. However, there has been a lack of support tools in the JS ecosystem, compared to what can be found on other platforms. A year ago, native BDD solutions similar to Cucumber were almost inexistant. Yet the need for it was manifest. It didn't take me long before I proposed and started hacking on the port of our favourite cucurbitaceae. Cucumber.js is a native JavaScript implementation of Cucumber. It is a strict port that can run on any JavaScript environment. It runs on Node.js as well as within any browsers, making it virtually serviceable against everything producing JavaScript and HTML (Node.js, Ruby on Rails, PHP, .Net, etc.). This is an introduction to the young Cucumber.js. After briefly exposing the history and goals of the project, I'll demonstrate how to write features, step definitions, hooks, support code, how to invoke it from both Node.js and browser environments. Presented at: - CukeUp! 2012: http://skillsmatter.com/podcast/agile-testing/cucumber-js-cuke-up-your-javascript - LNUG June 2012: http://lnug.org/TRANSCRIPT
![Page 1: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/1.jpg)
...Cuke up your JavaScript!
@cucumber_js
![Page 3: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/3.jpg)
Why?
![Page 4: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/4.jpg)
![Page 5: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/5.jpg)
![Page 6: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/6.jpg)
Behaviour-DrivenDevelopment
![Page 7: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/7.jpg)
Outside-in
![Page 8: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/8.jpg)
Tools?
![Page 9: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/9.jpg)
RSpec
![Page 10: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/10.jpg)
![Page 11: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/11.jpg)
?
![Page 12: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/12.jpg)
Bootstrap
![Page 13: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/13.jpg)
![Page 14: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/14.jpg)
![Page 15: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/15.jpg)
Environments
![Page 16: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/16.jpg)
Node.js
![Page 17: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/17.jpg)
CLI apps
![Page 18: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/18.jpg)
Selenium
Web apps
![Page 19: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/19.jpg)
zombie.js, phantom.js, ...
Headless web apps
![Page 20: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/20.jpg)
Browser
![Page 21: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/21.jpg)
Web apps
![Page 22: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/22.jpg)
Cukecipes
![Page 23: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/23.jpg)
![Page 24: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/24.jpg)
Getting started
![Page 25: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/25.jpg)
features/manage_recipes.feature
![Page 26: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/26.jpg)
![Page 27: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/27.jpg)
![Page 28: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/28.jpg)
World
![Page 29: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/29.jpg)
![Page 30: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/30.jpg)
![Page 31: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/31.jpg)
app/models/recipe.js
![Page 32: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/32.jpg)
![Page 33: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/33.jpg)
Tags
![Page 34: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/34.jpg)
![Page 35: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/35.jpg)
Hooks
![Page 36: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/36.jpg)
![Page 37: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/37.jpg)
![Page 38: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/38.jpg)
Headless
![Page 39: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/39.jpg)
Manyworlds
![Page 40: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/40.jpg)
![Page 41: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/41.jpg)
features/support/world.js
![Page 42: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/42.jpg)
features/support/persistence_world.js
![Page 43: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/43.jpg)
Zombie.js
![Page 44: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/44.jpg)
![Page 45: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/45.jpg)
![Page 46: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/46.jpg)
Automated browser
![Page 47: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/47.jpg)
Selenium
![Page 48: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/48.jpg)
![Page 49: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/49.jpg)
![Page 50: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/50.jpg)
In-browser
![Page 51: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/51.jpg)
![Page 52: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/52.jpg)
![Page 57: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/57.jpg)
Anyone can cuke.
![Page 58: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/58.jpg)
![Page 59: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/59.jpg)
How to set the context?
![Page 60: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/60.jpg)
Photo: Richard Vantielcke - LudImaginary (http://www.ludimaginary.net)
![Page 61: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/61.jpg)
![Page 62: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/62.jpg)
Is it stable?
![Page 63: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/63.jpg)
itself
![Page 64: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/64.jpg)
Node.js & Ruby on Rails
![Page 65: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/65.jpg)
.net, PHP, Java, ...
![Page 66: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/66.jpg)
The future
![Page 67: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/67.jpg)
Kite
App
Browser
DSLStepdefs
SeleniumDriver
World
CukestallDriver
Zombie.jsDriver
iFrame
Zombie.js
Gherkin
EXPER
IMEN
TAL
![Page 68: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/68.jpg)
features/support/kite_world.js
EXPE
RIMEN
TAL
![Page 69: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/69.jpg)
features/support/kite_world.js
EXPE
RIMEN
TAL
![Page 70: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/70.jpg)
Cukestall
EXPE
RIMEN
TAL
![Page 71: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/71.jpg)
cucumber-html
![Page 72: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/72.jpg)
Catch up with Cucumber.rb
![Page 73: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/73.jpg)
Documentation
* This book does not exist, obviously.
![Page 74: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/74.jpg)
We need you!
![Page 75: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/75.jpg)
![Page 76: Cucumber.js: Cuke up your JavaScript!](https://reader031.vdocuments.us/reader031/viewer/2022020101/5553ab39b4c905d9448b484e/html5/thumbnails/76.jpg)