README
AromaMock - Mocking Framework for JavaScript and CoffeeScript
Aroma is a CoffeeScript Mock Framework. This of course means that it can be used to test and develop JavaScript, but in this document, I will address CoffeeScript, because I like it better. It provides a useful scenario-expectations construct and easy, on the fly mock object generation.
The scenario verifies the exact expected function call sequence including the function arguments. Scenarios are specified before the code is run, making the tests well organized, readable and more explicit.
The scenario abstraction verifies that things happen exactly as specified: i.e. we do not only verify that some mock function was called with specific paramenter, we verify that it has not been called more times that it should have been, with some other parameters.
Original concepts were carried over from Voodoo-Mock, a C++/Python unit test framework.
Installation
$ npm install aroma-mock
You will also probably want to
$ npm install mocha coffee-script
Running CoffeeScript Tests with Mocha
In the following examples I use Mocha for a test runner. In order for Mocha to work with CoffeeScript you must use it like this:
$ mocha --compilers coffee:coffee-script/register [tests...]
Using Aroma-Mock with JavaScript
Aroma-Mock is written in CoffeeScript. It can be used in JavaScript by requiring the coffee-script/register
in your test code, and then requiring aroma-mock
:
Quick Start
Here's an example test, that mocks the jQuery $ symbol and tests that it is
used as expected. Before reading the entire thing, let's just look at the call
expectation:
call( '