javascriptjqueryunit-testingmockingqunit

What are some JavaScript unit testing and mocking frameworks you have used?


My main JavaScript framework is jQuery, so I would like my unit test and mocking frameworks to be compatible with that. I'd rather not have to introduce another JavaScript framework.

I am currently using QUnit for unit testing and Jack for mocking, but I am pretty new to the whole unit testing of JavaScript.

Is there a better tool to suggest? What has worked for you?


Solution

  • QUnit
    jqUnit
    Writing JavaScript tests with QUnit and jqUnit

    QUnit is the unit testing framework for the jQuery JavaScript framework. The testing framework itself uses the jQuery library, but the tests can be written for any JavaScript and do not require the code to use jQuery.

    jqUnit is a modified version of QUnit that adds in the setup, teardown, and assert functions that are more typical of an xUnit framework, and encapsulates everything in one global variable.

    The visual interface of the testrunner page is nice, allowing you to drill down and see each assert in every test method. Writing tests is fairly easy, and you can run the test code directly on the testRunner page [8]. This allows for easy and visible DOM testing.

    QUnit: MIT or GPL (choose) jqUnit: MIT License

    Pros

    Cons