Sugartest

SugarTest makes it easy to write elegant and understandable JavaScript tests. Its API is inspired by both RSpec, Shoulda and jQuery. It works as a DSL running on top of JsUnitTest.

Features:

Check the SugarTest tutorial for usage information.

Download SugarTest

SugarTest has been created by Choan Galvez and is freely distributable under the terms of a MIT-style license. The source code resides in a Git repository at github. SugarTest Logo designed by Ale Muñoz, released under a WTFPL License. SugarTest is a fork of jShoulda featuring a revised syntax and new features.

Example test

SugarTest()
  .describe('A context')
    .before(function(data) {
      data.something = 1;
    })
    .it('runs its setup function', function(data) {
      this.assertEqual(1, data.something);
    })
    .describe('which is an inner context')
      .before(function(data) {
        data.something += 1;
      })
      .it('runs both setup functions', function(data) {
        this.assertEqual(2, data.something);
      })
    .end()
  .end()
.run();

Live result

Tests results will be displayed here.