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

Gilles Lenfant gilles.lenfant at ingeniweb.com
Sun Dec 13 23:25:18 UTC 2009


Le 13 déc. 09 à 23:03, René Pijlman a écrit :

> 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?

Have a look at kss.core testings. JS is tested with ecmaunit.js  
powered by a rhino JS engine. There's also a "runner.html" to run all  
these tests through a real browser.

These are pure unit tests.

For TinyMCE full testing (browser + server), you should consider  
playing with selenium/selenium-rc. Google will tell you more.

Hope these starters will help.
-- 
Gilles Lenfant





More information about the Product-Developers mailing list