suitest

v0.0.3
Suitest is a powerful and easy-to-use JavaScript test suite
unit tests unit tests testing javascript nodejs tdd

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();

Screenshot

Suitest

.test ( name, callback, [, context ] );

var unit = new Suitest;

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

.exec ( x, [, y, context ] );

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

.done ( [ name ] );

Simple using:

unit.done();

Testing asynchronous code:

unit.test('test name', function(unit) {
    setTimeout(function() {
        unit.exec(true, 1); // true
        unit.done();
    }, 2000);
});

.text ( description );

unit.text('Test description');

.stop ();

unit.stop();

.is ()

unit.exec(true, 1);
unit.is(); // true

.get ( name );

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
});

Chaining (Fluent interface)

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();
});

##.

Metadata

Downloads

Maintainers