DailyJS

Gerbil, Smoking, URI.js

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries testing node browser

Gerbil, Smoking, URI.js

Posted by Alex R. Young on .
Featured

libraries testing node browser

Gerbil, Smoking, URI.js

Posted by Alex R. Young on .

Gerbil

Gerbil (npm: gerbil) by Bruno Aguirre is a test framework for both Node and client-side development. Tests are structured in a BDD-like style, and assertions are included. It's a small library but it offers a quick way to get started writing tests without many dependencies. I noticed that tests asynchronous code is supported because tests are run against a timeout, but there doesn't appear to be an explicit "this test is finished" method call to directly support asynchronous code.

Tests with Gerbil look like this:

scenario('This is a group of tests', {  
  'should assert true': function(g) {
    g.assert(true);
  }
});

Smoking

Smoking (npm: smoking), also by the same author, is a mocking and stubbing library. Prototype classes can be stubbed, and then expectations can be defined:

smoking(anObject).expects('aMethod');  
smoking(anObject).verify();  

When verify fails an exception will be raised, so this should be handled by most testing libraries.

URI.js

URI.js (GitHub: medialize / URI.js, License: MIT and GPL v3) by Rodney Rehm is a library for manipulating URIs that has a method chaining API. It makes manipulating everything from authentication details to query strings extremely easy:

URI('http://dailyjs.com/example.html')  
  .directory('files')
  .hash('header')
  .query('field', 'value')
    // http://dailyjs.com/files/example.html?field=value#header

For a complete list of methods, see the URI.js API documentation.