This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: "QUnit" – news · newspapers · books · scholar · JSTOR (February 2015)
This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: "QUnit" – news · newspapers · books · scholar · JSTOR (February 2015) (Learn how and when to remove this message)
Initial release8 May 2008 (2008-05-08)
Stable release
2.20.1[1] Edit this on Wikidata / 15 February 2024; 3 months ago (15 February 2024)
Written inJavaScript
TypeTest automation framework

QUnit is a JavaScript unit testing framework. Originally developed for testing jQuery, jQuery UI and jQuery Mobile, it is a generic framework for testing any JavaScript code. It supports client-side environments in web browsers, and server-side (e.g. Node.js).

QUnit's assertion methods follow the CommonJS unit testing specification, which itself was influenced to some degree by QUnit.


John Resig originally developed QUnit as part of jQuery. In 2008 it was extracted from the jQuery unit test code to form its project and became known as "QUnit". This allowed others to start using it for writing their unit tests. While the initial version of QUnit used jQuery for interaction with the DOM, a rewrite in 2009 made QUnit completely standalone.

Usage and examples

QUnit uses a set of assertion method to provide semantic meaning in unit tests:[2]

A basic example would be as follows:[3]

QUnit.test('a basic test example', function (assert) {
  var obj = {};

  assert.ok(true, 'Boolean true');       // passes
  assert.ok(1, 'Number one');            // passes
  assert.ok(false, 'Boolean false');     // fails

  obj.start = 'Hello';
  obj.end = 'Ciao';
  assert.equal(obj.start, 'Hello', 'Opening greet'); // passes
  assert.equal(obj.end, 'Goodbye', 'Closing greet'); // fails

See also


  1. ^ "Release 2.20.1". 15 February 2024. Retrieved 20 February 2024.
  2. ^ "Assert methods". QUnit API Documentation. Retrieved 2018-02-14.
  3. ^ "Cookbook: Example test". QUnit API Documentation. Retrieved 2014-06-02.