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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#