|
YUI Test
Although YUI Test is primarily a unit-testing framework, it does allow some simulations of the DOM and user interaction. Although its capabilities are not as complete as Selenium's or Watir's, it's a viable option, especially if you're already using it to test your JavaScript.
Utilities
A number of tools that don't fit into any particular category are very useful in developing JavaScript. In this section we'll take a look at tools that verify that you aren't committing basic crimes against JavaScript, shrink your code for production, and keep your code well documented.
JSLint
It can be tricky to write good JavaScript. Any number of corner cases can easily slip by if you're not paying attention. Add in the sheer volume of poorly written JavaScript that has been copied and pasted over the years and, well, you get a mess. JSLint examines your code looking for common errors and bad practices. If you follow its advice, you'll have better code when you're done. Your feelings might be hurt in the process, but the final result is worth it. To test your code, you can either cut and paste it into the verifier box (shown in Figure 7) on the JSLint Web site (where you can set a plethora of options) or you can run it from the command line, thanks to Rhino (an open source JavaScript implementation written in Java). |
|