mc

mocha-cucumber

Cucumber for Mocha -- two great tastes that taste great together!

Showing:

Popularity

Downloads/wk

28

GitHub Stars

23

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

mocha-cucumber

mocha-cucumber is a UI module for mocha that allows you to describe your features using Given/When/Then!

Installing

You should first have mocha installed:

npm install -g mocha

Then install mocha-cucumber, either globally or inside your project:

npm install -g mocha-cucumber

Usage

Write your feature(s):

{expect} = require 'chai'

Feature 'Math', ->
  Scenario 'Incrementing numbers', ->
    Given 'A number that starts at 0', ->
      @n = 0

    When 'the number is incremented', ->
      @n++

    Then 'it becomes 1', ->
      expect(@n).to.equal 1

Or if you prefer plan ole js:

var expect = require('chai').expect;

Feature('Math', function() {
  Scenario('Incrementing numbers', function() {
    Given('A number that starts at 0', function() {
      this.n = 0;
    });
    When('the number is incremented', function() {
      this.n++;
    });
    Then('it becomes 1', function() {
      expect(this.n).to.equal(1);
    });
  });
});

Then run mocha:

mocha --ui mocha-cucumber test/*

And you get: Example output

What's going on?

mocha-cucumber aliases Scenario and Feature as alieses to mocha's exising describe, and Given/When/Then/And/But as aliases to mocha's it BDD methods.

describe and it still work as usual, so you can combine your cucumber features with BDD specs and it will Just Work(tm).

Contributing

Feel free to submit issues and/or PRs! In lieu of a formal style guide, please follow existing styles.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100