Javascript BDD (2)
Just a quick add-on on my previous post, I found there was already a nice BDD framework for javascript : JSSpec.
Go see the demo page, it looks really nice.[…]
Javascript BDD
It was a long time since I delved into Scriptaculous subversion repository. This morning I was browsing it to find out what’s coming for next versions (seems 2.0 is not so far away) and had a good surprise : it seems they add BDD to their test framework.
I must admit my last try to use TDD for my Javascripts do not last long and this is a great reason to try again but this time BDD-Style.
To give you a little overview of what it looks like here’s a snippet extracted from the specs for the BDD framework itself :
Test.context("BDD-style testing",{
setup: function() {
...
},
teardown: function() {
...
},
'should provide extensions to tie in isSomething and respondsTo object methods': function(){
...
testObj.shouldBe('nice');
testObj.shouldNotBe('broken');
testObj.shouldRespondTo('isNice');
testObj.shouldRespondTo('isBroken');
},
'should automatically add extensions to strings': function(){
'a'.shouldEqual('a');
'a'.shouldNotEqual('b');
'a'.shouldNotBeNull();
'a'.shouldBeA(String);
}
}