For the last day of sprint, I wanted to set up a Javascript unit test
automation,

in order to be able to run all Js unitests like Python tests are through
buildbot.



Scriptaculous unit testing framework provides a way to do it: the tests
results are sent to a url through an Ajax call.



More infos on unit testing javascript here: Scriptaculous
Unit testing




Therefore, I have coded:


  • a small python script that launches html unit tests with
    mozilla-firefox, then close it
  • a small python http server that retrieves results sent by the
    javascript




Some caveats to correct before its useable in a Zope project:


  • Right now the results sent by the unit test is just a simple 'SUCESS'
    or 'ERROR' string, and I need to change it so I can get the full error log
    when they are errors, like the one displayed in the browser, and convert it
    to Python assertions.
  • The ajax call to send results is done from the filesystem html to the
    localhost. So a trick is needed to make cross-domain ajax posts. The python
    http server could be used to serve the html tests file as well to avoid
    this problem, so I would have a complete js test server.
  • It needs to work on IE as well, maybe through Wine





So to the question "Can I do TDD in JS as smoothly as in Python ?", I'd
answer: "Yes, it's coming up :)"



You can check the work here:
nuxeo.javascript cps tests




I might try to release the js test runner in a clean package sometimes, as
it might be reused.



This entry contains a screencast, you should check it in a browser


(Post originally written by Tarek Ziadé on the old Nuxeo blogs.)