Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: js
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (79 sloc) 2.196 kB

Gerbil

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. It's written in coffeescript so be nice with me

Now with npm

$ npm install gerbil

You can now execute the tests with node without to depend on the browser

var scenario = require('gerbil');
scenario("Testing with node", {
  "should work in a terminal": function(){
    assert(true);
  }
});

Console Errors

Example

scenario("This is my scenario", {
  "setup":  function(){
    // When scenario starts
    window.some_class = new MagicClass;
  },
  "before": function(){
    // Before every test
    some_class.magic_magic();
  },
  "after":  function(){
    // After every test
    some_class.clean();
  },
  "cleanup": function(){
    // When the scenario ends
    window.some_class = false;
  },

  "MagicClass should have a length": function(){
    some_class.add(1);
    assert_equal(some_class.length, 1);
  },

  "MagicClass should be valid": function (){
    assert(some_class.valid);
  }
});

Custom logger

var my_cool_logger = {
  "warn":   function(msg){},
  "log":    function(msg){},
  "error":  function(msg){
    alert(msg);
  },
};

scenario("Fancy scenario", {
  "somewhere over the rainbow": function(){
    assert(false);
  }
}, my_cool_logger);

// Change global logger

GerbilOptions.logger = my_cool_logger;

scenario("Fancy scenario is back", {
  "somewhere over the double rainbow": function(){
    assert(false);
  }
});

What's the catch?

The results are only shown in the console, the one from console.log Run it with an open inspector or define a custom logger

Console tests

And in the bottom you will find the summary

Console summary

TODO

  1. Get a gerbil as a pet

Contributors

Jump to Line
Something went wrong with that request. Please try again.