mocha-gherkin
mocha-gherkin
is a Gherkin-style interface and reporter add-on for mocha. This add-on allows you to describe your features using Feature
, Scenario
, Given
, When
, Then
, And
, and But
. You can use this interface together with mocha's BDD interface.
Usage in ECMAScript 6
;
Usage in ECMAScript 5
;
Installing
You should first have mocha installed:
$ npm install mocha
Then install mocha-gherkin
, either globally or inside your project:
$ npm install mocha-gherkin
How to Use
Actually, mocha-gherkin
consists of two different add-ons: interface add-on and reporter add-on. To use mocha-gherkin
, you should first write your features using terms provided by the interface add-on. Then, run mocha
with the options below:
$ mocha tests/addition.feature.js --ui mocha-gherkin --reporter mocha-gherkin/build/spec
What's Going on?
Feature
and Scenario
wrap around mocha's describe
, and Given
, When
, Then
, And
, and But
do the same thing for mocha's it
. describe
, context
, it
, and other mocha's BDD lingos still work as usal, so you can mix in them with the Gherkin-style terms.
Reporter Support
mocha-gherkin
has currently only one reporter add-on, which extends mocha's spec
with support for the Gherkin-style interface. However, you can use other modules as usual since mocha-gherkin
just wraps around mocha's BDD interface.