I'm starting a nodejs project and would like to do BDD with Mocha and Zombiejs. Unfortunately I'm new to just about every buzzword in that sentence. I can get Mocha and Zombiejs running tests fine, but I can't seem to integrate the two - is it possible to use Mocha to run Zombiejs tests, and if so, how would that look?
Just looking for "hello world" to get me started, but a tutorial/example would be even better.
Thanks!
Assuming you already have installed
mocha
,zombie
andexpect.js
according to instructions, this should work for you:Then you should be able to run the
mocha
command from your root application folder:Note: If your tests keep failing due to timeouts, it helps to increase
mocha
's timeout setting a bit by using the-t
argument. Check out mocha's documentation for complete details.if you want to use cucumber-js for your acceptance tests and mocha for your "unit" tests for a page, you can use cuked-zombie (sorry for the advertising).
Install it like described in the readme on github, but place your world config in a file called world-config.js
Then use mocha with zombie in your unit tests like this:
If you are using Microsoft Visual Studio, you might want to take a look at Rob Ashton's Zombify. Everything is acceptably integrated so you can start writing your test cases in JavaScript or CoffeeScript. By the way, learning CoffeeScript will take you like an hour, and it's worth every minute.
I wrote a lengthy reply to this question explaining important gotchas about asynchronous tests, good practices ('before()', 'after()', TDD, ...), and illustrated by a real world example.
http://redotheweb.com/2013/01/15/functional-testing-for-nodejs-using-mocha-and-zombie-js.html