Thursday, November 5th, 2009

Riot.js: JavaScript port of the lean fast unit test framework

Category: JavaScript, Testing

<>p>Riot started as a lean Ruby unit test framework with tests that have a style like this:

  1. context "a new user" do
  2.   setup { User.new }
  3.   asserts("that it is not yet created") { topic.new_record? }
  4. end

Alex Young has now implemented Riot.js which brings you the lean framework in a format that can run stand-along via Rhino, or through the browser itself with tests that look like:

javascript
< view plain text >
  1. Riot.run(function() {
  2.   context('basic riot functionality', function() {
  3.     given('some simple equality tests', function() {
  4.       asserts('a simple truth test should return true', true).isTrue();
  5.       asserts('isNull is null', null).isNull();
  6.     });
  7.  
  8.     given('another context', function() {
  9.       asserts('equals should compare strings as expected', 'test string').equals('test string');
  10.     });
  11.  
  12.     given('a context concerned with functions', function() {
  13.       asserts('asserts() should allow functions to be compared', function() {
  14.         return 'test string';
  15.       }).equals('test string');
  16.     });
  17.   });
  18.  
  19.   given('yet another context', function() {
  20.     asserts('equals should compare strings as expected', 'test string').equals('test string');
  21.   });
  22. });

Related Content:

Posted by Dion Almaer at 6:12 am
2 Comments

+----
1.6 rating from 65 votes

2 Comments »

Comments feed TrackBack URI

^ Hilarious spam post wuwei. Failed attempt in boosting Google search ranking.

I might give Riot a try, in need of a real simple Unit Tester for js.

Comment by davidck — November 9, 2009

Leave a comment

You must be logged in to post a comment.