A functional test suite based on jQuery
JavaScript CSS HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin Move script to bin folder. Mar 23, 2016
browser Override QUnit2.test instead of call sourcing Jun 28, 2017
doc/guides Finish the Node script for publishing the site Jul 19, 2017
examples add redirects for top-level examples pages that show up in top google… Oct 28, 2016
main Add Google Analytics Jul 20, 2017
site Add Google Analytics Jul 20, 2017
test Make func unit work with steal_qunit2 approach May 11, 2017
.editorconfig Adds a F.attach() function for attaching a test runner Apr 9, 2015
.gitignore Make func unit work with steal_qunit2 approach May 11, 2017
.gitmodules removed syn as a submodule, added as bower component. updated build t… Oct 8, 2013
.npmignore Add .npmignore file Oct 24, 2017
.travis.yml Test with Node 7 Jun 28, 2017
CNAME 162 - add site Oct 26, 2016
README.md Various spelling & grammar fixes Jan 9, 2017
build.js 198 - point to global.js in build but not in package.json Apr 11, 2017
documentjs.json Auto update version number on home page Mar 14, 2017
funcunit.js Upgrading to latest Steal Apr 9, 2015
funcunit.md Auto update version number on home page Mar 14, 2017
global.js use new global file for the build Apr 10, 2017
license.md Update and rename LICENSE to license.md May 27, 2015
package.json Upgrading FuncUnit to Syn 0.13 . This will bring in a lot of bugfixes… Nov 1, 2017
publish-docs.js Finish the Node script for publishing the site Jul 19, 2017
test.html #159 - refactors to be more canjs-like Oct 24, 2016



Build Status npm version Join the chat at https://gitter.im/bitovi/funcunit

Write better tests, faster.

Note: FuncUnit Roadmap

The FuncUnit Getting Started guide is a quick walkthrough of creating and running a test.

Set up a test

QUnit provides the basic structure needed to write unit or functional tests.


Modules are groups of tests with setup and teardown methods that run for each test.

module("Contacts", {
  // runs before each test
  setup: function(){
    // setup code
  // runs after each test
  teardown: function(){
    // cleanup code


test("findOne", function(){
  // define a test


test("counter", function() {
  ok(Conctacts.first().name, "there is a name property");
  equal(Contacts.counter(), 5, "there are 5 contacts");

Open a page

The following uses F.open( URL ) to open autocomplete.html before every test.

module("autosuggest", {
  setup: function() {

Calling open on window will cause FuncUnit commands to operate on the current window. This is also the default if you don't open any page.

Query for elements

FuncUnit tests are written just like jQuery. F is a copy of the $ method. It is used to find elements in the page you're testing. Like $, FuncUnit methods are chainable on the results of F.

// grab the #description element, wait for it to be visible, type in it
F("#description").visible().type("Test Framework");

Simulate user actions

When you're testing a widget, you need to simulate the actions that user takes. FuncUnit uses the syn library to accurately simulate the correct low level events like mouseup and keypress for high level actions like click() and type(). The following shows how to simulate common user actions.


// click a button


// type in an input
F('#task_name').type("Learn FuncUnit");


// drag a task item to the trash area

Wait for page conditions

After a user action, your test page's event handlers run and the page is changed. Wait commands are used to wait for some page condition before continuing.

Waits are overloaded jQuery getter methods. F.fn.text( textVal, callback ) waits for an element's $.fn.text to match the textVal.

// wait for result to show "task complete"
F("#result").text("task complete");


// wait for first result to be visible


// after clicking a menu item, wait for its width to be 200px


// wait for the input value


// wait for number of matched elements

There are many more waits possible.

Get information and run assertions

After simulating an action and waiting for the page to change, you often want to get information about an element and run assertions. You can use jQuery getter methods in combination with QUnit assertions.

These methods (which return synchronous results) are used in callbacks that run after a wait method completes.

// wait until we have some results, then call the callback
  equal( F('.autocomplete_item').size(), 5, "there are 5 results");

Running in browser

These tests can be loaded in any browser. The app page opens in a separate window and results show up in the QUnit page.

test("JavaScript results", function(){

  // wait until we have some results
    equal( F('.autocomplete_item').size(), 5, "there are 5 results");