suitest

Suitest is a powerful and easy-to-use JavaScript BDD test suite

Suitest

Suitest provides easy unit testing for JavaScript code

  • Very simple to use
  • Client-side and server-side (including NodeJS) support
  • One of the most lightweightest libraries for unit testing
  • Support for working with asynchronous code
  • Outline function callbacks!
  • Fluent interface support (chaining)

##Synopsis:

.test( name, callback, [, context ] );
.exec( x, [, y, context ] );
.done( [ name ] );
.text( description );
.stop();
.get();
.is();

var unit = new Suitest;
 
unit.test('test name', function(unit) {
    unit.exec(true, 1); // true 
    unit.done();
});

Using with one parameter:

unit.exec(true); // true 

Using with two parameter:

unit.exec(true, 1); // true, because default operation is == 

Using with three parameters:

unit.exec(true, 1, '==='); // false, because true and 1 are not equivalent 

Simple using:

unit.done();

Testing asynchronous code:

unit.test('test name', function(unit) {
    setTimeout(function() {
        unit.exec(true, 1); // true 
        unit.done();
    }, 2000);
});
unit.text('Test description');
unit.stop();
unit.exec(true, 1);
unit.is(); // true 

Outline function callback

var set = function() {
    return unit
        .get('test 6')
        .exec(true, 1)
        .done();
};

Simple using

unit.test('test', function(unit) {
    set(); // true 
});

Using with asynchronous code

unit.test('test', function(unit) {
    setTimeout(set, 2000); // true 
});

Function.prototype.bind / Function.prototype.call
Also you can use it without <get> method (but this not recommended):

var set = function() {
    return this
        .exec(true, 1)
        .done();
};
 
unit.test('test', function(unit) {
    set.call(this); // true 
});
var unit = new Suitest;
 
unit
.test('test 1', function(unit) {
    unit.exec(true, 1).done();
})
 
.test('test 2', function(unit) {
    unit.text('test description').exec(true, 1).done();
})
 
.test('test 2', function(unit) {
    if (!unit.exec(true, 1).is())
        unit.stop();
});

##.

  • License Suitest is licensed under the MIT (MIT_LICENSE.txt) license

  • Copyright (c) 2012 [Alexander Guinness] (https://github.com/monolithed)