JavaScriptMVC's Test Plugin Making JavaScript Testing Easier


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

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;
   // 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!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <div> <blockquote> <object> <embed> <img> <param>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.