Gerbil
n. Gerbils: Inquisitive, friendly animals that rarely bite, TDD for the rest of us
Gerbil attemps to be an uber simple and minimalistic testing framework for javascript.
Now with npm
$ npm install gerbil
Or just include the .js and run tests within a normal browser.
You can now execute the tests with node without to depend on the browser
var scenario = scenario; ; // Or if you want to access some global Gerbil stuff var Gerbil = ;var scenario = Gerbilscenario;
What it's included?
assert
Good ol' assert, checks boolean.
assertEqual
Just like assert but checks types AND value.
assertThrow
Asserts the throw of an exception.
assertType
Asserts the type of the object to evaluate.
pending
Mark the test as pending.
setTimeout
Run the test within a time.
async
Run async code. Eg. callbacks, timers.
Example output
Walkthrough
// Name the scenario you want to test and pass an object with your tests.;
Example
;
Scenario config and global config.
var myCoolFormatter = // Passing tests {} // Failing tests {} // Pending tests {} // The start of a scenario {} // Report at the end of a scenario {}; ; // Or if you want to affect every gerbil scenario GerbilglobalConfig = formatter: myCoolFormatter
Callbacks
Withing the config object you can add two types of callbacks, 'start' and 'finish'. This can help you to trigger events after the scenario finished or a nice sand clock when it starts.
; // Of course you can define then globally: GerbilglobalConfig = {} {};
What's the catch?
The results are only shown in the console, the one from console.log if you use it in a browser. Run it with an open inspector or define a custom formatter if you want prettier results. And in the bottom you will find the summary
TODO
- Get a gerbil as a pet