Syntax
Entry Points: describe, when, then, it
Example:
describe("Name", function() {
// Test logic here
});
Nesting
Nest as much as you want
describe("Outer test", function() {
when("there's an inner test", function() {
then("it all works!", function() {
});
});
then("again if you want", function() {
});
});
Running
Open the test page to see the results
file:///C:/code/steve/basil/tests/samples/index.html
Results
Results shown hierarchically
Red = Fail
Green = Pass
Use the "Hide Passed" checkbox if you only care about reds
Expand/Collapse at will - it will remember your selection between page loads
(via localStorage if there's browser support)
How it runs
Test setup is rerun from the root for every leaf node
This ensures a clean slate in your text fixture
Example
describe("Rerunning", function() {
var foo = "bar";
when("changing foo", function() {
foo = "baz";
then("it is baz", function() {
foo.should.equal("baz");
});
});
then("it is bar", function() {
foo.should.equal("bar");
});
});
So what actually executed?
First Test:
var foo = "bar";
foo = "baz"
foo.should.equal("baz")
Second Test:
var foo = "bar"
foo.should.equal("bar")
But wait, isn't that slow?
We have around 1500 leaf nodes running in about 10 seconds
So yes, a little slow. If only there was...