QUnit
   HOME

TheInfoList



OR:

QUnit is a
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
unit testing framework. Originally developed for testing jQuery, jQuery UI and
jQuery Mobile jQuery Mobile is a touch-optimized web framework (also known as a mobile framework), specifically a JavaScript library, developed by the jQuery project team. The development focuses on creating a framework compatible with many smartphones and ta ...
, it is a generic framework for testing any JavaScript code. It supports
client-side Client-side refers to operations that are performed by the client in a client–server relationship in a computer network. General concepts Typically, a client is a computer application, such as a web browser, that runs on a user's local comput ...
environments in web browsers, and server-side (e.g.
Node.js Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript cod ...
). QUnit's assertion methods follow the CommonJS unit testing specification, which itself was influenced to some degree by QUnit.


History

John Resig John Resig is an American software engineer and entrepreneur, best known as the creator and lead developer of the jQuery JavaScript library. , he works as the chief software architect at Khan Academy. History Resig graduated with an undergraduate ...
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.module(string) - Defines a module, a grouping of one or more tests. * QUnit.test(string, function) - Defines a test. QUnit uses a set of assertion method to provide semantic meaning in unit tests: * assert.ok(boolean, string) - Asserts that the provided value casts to boolean true. * assert.equal(value1, value2, message) - Compares two values, using the double-equal operator. * assert.deepEqual(value1, value2, message) - Compares two values based on their content, not just their identity. * assert.strictEqual(value1, value2, message) - Strictly compares two values, using the triple-equal operator. A basic example would be as follows: QUnit.test('a basic test example', function (assert) );


See also

*
List of unit testing frameworks This article is a list of tables of code-driven unit testing frameworks for various programming languages. Some, but not all, of these are based on xUnit. Columns (classification) * Name: This column contains the name of the framework and w ...
*
Jasmine Jasmine ( taxonomic name: ''Jasminum''; , ) is a genus of shrubs and vines in the olive family (Oleaceae). It contains around 200 species native to tropical and warm temperate regions of Eurasia, Africa, and Oceania. Jasmines are widely culti ...
* JavaScript framework * JavaScript library


References


External links

* * {{JavaScript JavaScript programming tools Unit testing frameworks Free software programmed in JavaScript