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.
The current version of Yadda is 0.15.1
Breaking changes were introduce in versions 0.15.0 and 0.13.0.
Please refer to the Release Notes for more details
Please refer to the the Yadda User Guide.
.├── bottles-test.js├── lib│ └── wall.js└── test├── features│ └── bottles.feature└── steps└── bottles-library.js
Feature: 100 Green BottlesScenario: Should fall from the wallGiven 100 green bottles are standing on the wallWhen 1 green bottle accidentally fallsThen there are 99 green bottles standing on the wall
var assert = require'assert';var English = require'yadda'localisationEnglish;var Wall = require'../../lib/wall'; // The library that you wish to testmoduleexports =return Englishlibrarygiven"$NUM green bottles are standing on the wall"wall = number;next;when"$NUM green bottle accidentally falls"wallfallnumber;next;then"there are $NUM green bottles standing on the wall"assertequalnumber wallbottles;next;;;
(If your test runner & code are synchronous you can omit the calls to 'next')
var Yadda = require'yadda';YaddapluginsmochaStepLevelPlugininit;'./test/features'eachfeatureFilefilevar library = require'./test/steps/bottles-library';var yadda = YaddacreateInstancelibrary;scenariosfeaturescenariosstepsscenariostepsyaddarunstep done;;;;;
thisbottles = bottles;thisbottles -= n;;
mocha --reporter spec bottles-test.js100 Green BottlesShould 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