Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including diet-yadda with all npm packages installed. Try it out:

var dietYadda = require("diet-yadda")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

diet-yadda v0.22.2

A true BDD framework for JavaScript - slimmed down


Build Status Dependencies Gitter NPM

Yadda brings true BDD to JavaScript frameworks such as Jasmine, Mocha, QUnit, Nodeunit, WebdriverIO and CasperJS. By true BDD we mean that the ordinary language (e.g. English) steps are mapped to code, as opposed to simply decorating it. This is important because just like comments, the decorative steps such as those used by Jasmine, Mocha and Vows can fall out of date and are a form of duplication.

Yadda's BDD implementation is like Cucumber's in that it maps the ordinary language steps to code. Not only are the steps less likely to go stale, but they also provide a valuable abstraction layer and encourage re-use. You could of course just use CucumberJS, but we find Yadda less invasive and prefer it's flexible syntax to Gherkin's. Yadda's conflict resolution is smarter too.

Latest Version

The current version of Yadda is 0.22.1
There are breaking changes (steps default to async rather than synchronous when variadic arguments are used in steps). Please refer to the Release Notes for more details.


Please refer to the the Yadda User Guide.


Step 1 - Decide upon a directory structure, e.g.

├── bottles-test.js
├── lib
│    └── wall.js
└── test
    ├── features
    │   └── bottles.feature
    └── steps
        └── bottles-library.js

Step 2 - Write your first scenario


Feature: 100 Green Bottles

Scenario: Should fall from the wall

   Given 100 green bottles are standing on the wall
   When 1 green bottle accidentally falls
   Then there are 99 green bottles standing on the wall

Step 3 - Implement the step library


var assert = require('assert');
var English = require('yadda').localisation.English;
var Wall = require('../../lib/wall'); // The library that you wish to test

module.exports = (function() {
  return English.library()
    .given("$NUM green bottles are standing on the wall", function(number, next) {
       wall = new Wall(number);
    .when("$NUM green bottle accidentally falls", function(number, next) {
    .then("there are $NUM green bottles standing on the wall", function(number, next) {
       assert.equal(number, wall.bottles);

(If your test runner & code are synchronous you can omit the calls to 'next')

Step 4 - Integrate Yadda with your testing framework (e.g. Mocha)


var Yadda = require('yadda');

new Yadda.FeatureFileSearch('./test/features').each(function(file) {

  featureFile(file, function(feature) {

    var library = require('./test/steps/bottles-library');
    var yadda = Yadda.createInstance(library);

    scenarios(feature.scenarios, function(scenario) {
      steps(scenario.steps, function(step, done) {, done);

Step 5 - Write your code


module.exports = function(bottles) {
  this.bottles = bottles;
  this.fall = function(n) {
    this.bottles -= n;

Step 6 - Run your tests

  mocha --reporter spec bottles-test.js

  100 Green Bottles
    Should fall from the wall
      ✓ Given 100 green bottles are standing on the wall
      ✓ When 1 green bottle accidentally falls
      ✓ Then there are 99 green bottles standing on the wall


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free