Recipe 31Drive JavaScript/CoffeeScript Using Cucumber-JS

Problem

You’re testing JavaScript code that’s running either on the server side in a framework like Node.js or in the browser. You’d like to use the familiar Cucumber syntax to drive your JavaScript (or possibly CoffeeScript) code.

Ingredients

  • Cucumber-JS,[196] an implementation of Cucumber written in JavaScript

  • Node.js (or just Node),[197] a JavaScript application framework

  • Node Package Manager,[198] the main way of installing libraries into Node

  • CoffeeScript,[199] a more elegant syntax for JavaScript

Solution

JavaScript runs in a lot of environments, from GUI code in the browser to back-end server frameworks like Node.js. In this recipe, we’re going to write a simple Cucumber test for some ...

Get Cucumber Recipes now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.