Last Updated: February 25, 2016
·
1.008K
· rendro

Mocha tests with Rspec-given syntax

Mocha-given is a mocha interface that helps you write cleaner specs using Given, When, Then, And and Invariant.

It strives to enable every JavaScript developer to test their code without any brace-hell using a syntax that is easy to read and comprehensible.

Using CoffeeScript and mocha-given reduces your tests to this:

describe 'assigning stuff to this', ->
    Given -> @number = 24
    When  -> @number++
    And   -> @number *= 2
    Then  -> @number == 50
    And   -> @number != 51

Run the test with mocha:

$ ./node_modules/.bin/mocha -u mocha-given --compilers coffee:coffee-script -R spec ./testFolder/

Writing test should be as easy as this!

Please start writing tests

https://github.com/rendro/mocha-given