In Node.js
In the browser
Getting Started in the browser
Guides
Check these QUnit tutorials and examples, to make the most of your unit tests!
- QUnit.module: How to group related tests.
- QUnit.test: Define tests, How to wait for async code
- Fixture feature: Keeping your DOM tests atomic.
- Step API: Testing asynchronous callbacks or event listeners.
- Assertions: Partial object comparison, expected exceptions, and much more.
- Browser: Productivity tricks, Browser automation, What can the toolbar do?
- CLI: Productivity tricks, Code coverage.
Support
To report a bug or request a new feature, open an issue.
If you need help using QUnit, join us in the Matrix chat!
Linting
The eslint-plugin-qunit package has a variety of rules available for enforcing best testing practices as well as detecting broken tests.
Download
These are the official release channels for QUnit releases:
-
Download:
You can save the
qunit-2.22.0.js
andqunit-2.22.0.css
files directly from the jQuery CDN. For older versions, browse the release archives.Or download them via the terminal, and save them in your Git repository.
curl -o qunit.css 'https://code.jquery.com/qunit/qunit-2.22.0.css' curl -o qunit.js 'https://code.jquery.com/qunit/qunit-2.22.0.js'
-
npm Registry:
If your development workflow uses Node.js, you can install the qunit package the npm Registry, using the
npm
CLI:npm install --save-dev qunit
Or, if using Yarn:
yarn add --dev qunit
You can then reference
node_modules/qunit/qunit/qunit.css
andnode_modules/qunit/qunit/qunit.js
in your HTML.If your project uses a custom npm frontend that locates packages elsewhere, you may need to generate the HTML dynamically and use
require.resolve()
to locatequnit/qunit/qunit.js
andqunit/qunit/qunit.css
. Alternatively, use one of the Integrations such as karma-qunit which can do this for you. -
Bower:
QUnit 1.x and QUnit 2.x releases were published to Bower, and remain available there under the
qunit
package.For QUnit 3.0 and later, either download and commit the JS and CSS file directly in your project (e.g. using the curl command above), or install the
qunit
package from npm as a dev dependency.
Further reading
- Read QUnit documentation offline, via DevDocs.
- Introduction to JavaScript Unit Testing, Jörn Zaefferer (2012).