[Sugar-devel] Unit tests in Sugar HTML
Manuel Quiñones
manuq at laptop.org
Mon May 13 10:22:41 EDT 2013
Hello,
As I am currently implementing sugar palettes in HTML, I want to get
the logic right, so I need unit tests. Then I started to investigate
unit testing in javascript.
After looking for a bit, I decided to give a try to Jasmine framework,
which is AngularJS choice.
http://pivotal.github.io/jasmine/
My first attempt was running the tests in the command line with jasmine-node.
https://github.com/mhevery/jasmine-node
But soon I realized that testing without access to the DOM is very
limited. For example, a palette needs to add a <div> to the document.
And my second test failed in jasmine-node because of that.
So I went for Karma (previously named Testacular).
http://karma-runner.github.io/
It was easy to configure using RequireJS like is documented in:
http://karma-runner.github.io/0.8/plus/RequireJS.html
And it works! You can try installing Karma (npm install -g karma) and
then checking out in my clockjs activity.
git checkout git://github.com/manuq/clockjs.git
cd clockjs/lib/sugar-html-graphics
karma start
And then point a browser to the URL in the output, which points to Karma server.
--
.. manuq ..
More information about the Sugar-devel
mailing list