Sunday, 23 December 2012

Yadda yadda yadda

Rob Fletcher's excellent Grails For Hipsters session at this year's Groovy and Grails exchange inspired me to have a play with CasperJS. It's a super fast, super slick, headless web test tool built on PhantomJS. Unfortunately there is a price to pay.

1. PhantomJS is a headless webkit implementation so your tests won't run against Firefox or IE.
2. There's no BDD support.

I can't do much about #1 but there was something I could do about #2. Back in the day I wrote an extension to Selenium IDE providing cucumber/gherkin like language support. It was pretty clunky, but functional (no pun intended). I dusted it off, removed the Selenium cruft, renamed it "yadda" and github'd it here. You can now write your CasperJS tests like this...

   "When I open Google's fr search page",
   "then the title is Google",
   "and the search form exists",
   "When I search for foo",
   "then the title is foo - Google Search",
   "and the search for foo was made",
   "and 10 or more results were returned"
]); {

Since the yadda core is just a library for mapping steps (e.g. "When I search for foo"), to javascript functions, it will work without CasperJS and can hopefully be plugged into other JS testing frameworks without too much difficulty. Feel free to fork the project and send me a pull request if you do so.