jShoulda acts as a wrapper to the JsUnitTest library, allowing you to write JavaScript unit tests in a Shoulda-like language.
context('A test', {
setup: function() {
this.foo = 1;
}
},
should('run its setup functions', function() {
this.assertEqual(1, this.foo);
}),
context('which is a "nested" test', {
setup: function() {
this.foo += 1;
}
},
should('run both setup functions', function() {
this.assertEqual(2, this.foo);
})
)
)();
The tests results will be displayed here.
Note: in March, 2009, the author abandoned work in jShoulda in favor of SugarTest, a new library wich uses an improved and richer syntax (and still works on top of JsUnitTest).
Interested? Check our tutorial on jShoulda (or this screencast with Spanish audio track).
Still writing too much? Watch and get the jShoulda TextMate Bundle.
jShoulda 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.