xUnit – JavaScript Unit Testing Extension

The Brackets xUnit extension was created to simplify the process of creating and developing Javascript unit tests. xUnit currently supports the unit test frameworks Jasmine, Qunit, and YUITest. Tests written in these frameworks can be run directly from the Brackets interface. The extension can also generate skeleton unit tests for Jasmine, Qunit, or YUITest by parsing the current file and creating a new test file with test cases for each method.


The goal of the extension is to help with the setup and execution of unit tests during creation so the user can focus on the test content. Once installed the extension will detect a file is a unit test by it’s extension or content. The unit test will have a menu item in the project context menu to run the test. The extension generates the necessary framework files and html to run the test and display the results in brackets.

Running Tests

Once installed you can open the brackets-xunit/samples directory in brackets. When right-clicking any of the test files in the file navigator a menu item to run the test will appear. For example click on the jasmine.spec.js file and select Run Jasmine xUnit Test. You will see a new window appear with the title Jasmine Test – jasmine.spec.js. Inside the window will be the jasmine test results. The results appear the same as if you downloaded Jasmine and ran in a browser. You may then modify the test file, change test values or add new tests. After saving, rerun the test to view the results. If you encounter problems, it is useful to be able to edit and rerun tests quickly to get instant feedback.

Creating New Tests

A new feature in the extension is the ability to create skeleton unit tests. In the samples/simpleapi directory, right-click on the mathfns.js file to generate a skeleton unit test file for Jasmine, Qunit, or YUITest. Selecting Generate Jasmine will create a new file called mathfns.spec.js. The file contains a unit test describe function for each of the 4 methods defined in the mathfns.js file. Each “describe” function contains an “it” function with an “expect” assertion. You can fill in the parameter values and expected values to make a unit test for the function. The test generation feature is meant to help you get started writing unit tests for an api in any of the supported unit test frameworks.


The extension also uses the built-in node.js server to run additional scripts. Any shell scripts with #!/usr/bin in the header can be run. Try clicking on each of the scripts in the sample directory to see their output as they run inside brackets. The file is a bash shell script, runs python, and nodescript.js is a node.js script with JavaScript code.

There is also experimental support for running test262 (the ECMAScript standard) tests from within Brackets. The extension is still under development. Let us know if you have any feedback or suggestions.

See It In Action

Here is a short video that highlights all the features of xUnit.

The video cannot be shown at the moment. Please try again later.

1 Response

One Comment

  1. Gagan M says:

    The extension package seems to be broken ! Can you update the extension registry please ?

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


− 5 = one