[Product-Developers] How to write unit tests around a Javascript function?

René Pijlman reneOnLists at applinet.nl
Sun Dec 13 22:03:55 UTC 2009


Hi,

I'm debugging this issue in TinyMCE:
http://plone.org/products/tinymce/issues/134

It turns out it's a bug in a client-side Javascript function of TinyMCE 
that computes a relative link from the absolute paths of the current 
page and the page being linked to. It's easy enough to fix and easy 
enough to write some ad hoc Javascript test code, e.g. by executing it 
interactively in a browser.

But is there an agreed-upon way to add unit tests to Javascript code of 
products in the Collective? Tests that can be executed by a 
non-interactive / command line Javascript interpreter as part of the 
automated testing procedures?

Martin's testing tutorial covers only Python code and Python doctests:
http://plone.org/documentation/kb/testing
And zope.testrecorder seems overly complex, for unit testing a pure 
function with two string parameters in and one string result out.

This particular bug probably needs to be fixed in upstream TinyMCE, but 
I'm still curious how this is done in the Plone world. Also, if 
possible, I'd like to add unit tests to Products.TinyMCE to catch 
regression bugs in upstream TinyMCE.

-- 
René
http://www.applinet.nl




More information about the Product-Developers mailing list