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
Written by Robert Fleischmann
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
iam4x
94.17K
ericdfields
63.02K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#