Share

From this page you can share JavaScriptMVC's Test Plugin Making JavaScript Testing Easier to a social bookmarking site or email a link to the page.
Social WebE-mail
Enter multiple addresses on separate lines or separate them with commas.
JavaScriptMVC's Test Plugin Making JavaScript Testing Easier
(Your Name) has forwarded a page to you from Ajaxonomy
(Your Name) thought you would like to see this page from the Ajaxonomy web site.

JavaScriptMVC's Test Plugin Making JavaScript Testing Easier

Tagged:  

You may remember me writing about JavaScriptMVC about a month ago. Well, they have made a very cool plug-in for JavaScriptMVC (although you can also use the plug-in for non-JavaScriptMVC features) called Test that makes JavaScript testing much easier.

Below is an excerpt from the post on the plug-in.

Easy to use

Test is optimized for easy use. But, every library
says that. Here's why we mean it:

1. JavaScriptMVC's Console provides helpful messages to guide you through
setup

Test runner window

2. Asynchronous event tests avoid using nested functions to keep your
code easier to understand

test_open: function(){
   // a controller action helper doubleclicks the second directory
   this.next(this.DirectoryDblclick(2));
   // call the next function when the open animation is complete

},
assert_open: function(params){
   // check there are 5 files in the directory
   this.assertEqual(5, params.element.childNodes.length);
}
Asynchronous event testing

3. If you use Controller, helper methods are automatically created that
simulate each controller action's event, such as TodoClick

4. Event simulation syntax so simple your grandma could understand it2

this.Keypress(element, 'h'); // Test syntax
YAHOO.util.UserAction.keypress(element, { charCode: 72 }); // Yahoo syntax
Event simulation syntax comparison

You can read the full post and see a demo of the plug-in here.

Further more the plug-in does more than just unit tests. It lets you simulate user interactions with your page:

  • Cross browser support for typical DOM events, like keypress, click, submit, blur, and focus
  • Simulate writing text or dragging an element

This plug-in looks pretty good and I plan on using it in a future application using JavaScriptMVC. Anything that makes JavaScript testing easier is a very good thing!