banner design

Developers generally neglect JavaScript testing because there’s really nothing out there that let’s you simulate user interactions easily.  Here comes the Test plugin (Thanks to Brian Moschel from JavaScriptMVC for suggesting this resource).

It lets you simulate every major DOM event, as well as some combination events like Write and Drag, and then run functional and unit tests in a separate console window.

JavaScript Test

Test plugin saves serious development time with features like using sample data to simulating AJAX functionality, writing text or dragging an element.

Here is a sample test function:

test_check : function() {
    // simulate clicking the checkbox
    // params has the todo element
    var params = this.TodoCheckClick();
    // assert the color change occurs as expected
    this.assert_equal("#808080", params.element.parentNode.style.color);
},
test_uncheck : function() {
    // click the checkbox again to uncheck it
    var params = this.TodoCheckClick();
    // assert the color change goes away
    this.assert_equal('', params.element.parentNode.style.color);
},

WebResourcesDepot Feed