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.
- Reporter API: Event emitter, Create your own reporter.
- Theme API: Create your own theme.
Support
To report a bug, request a new feature, or ask a question open an issue on GitHub.
You can also find support on StackOverflow. Use the “qunit” hashtag on StackOverflow to search existing questions or ask your own question.
Chat
If you need help, join us in our chat room on Matrix at #qunitjs_qunit:gitter.im
:
- Gitter web client, browse the room as guest.
- Element web client, join and log in (with GitHub, GitLab, Google, or Apple ID), or sign up.
- matrix.to link, join with the Element native app or other Matrix client.
Social media
Follow us:
Hashtags:
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.23.1.js
andqunit-2.23.1.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.23.1.css' curl -o qunit.js 'https://code.jquery.com/qunit/qunit-2.23.1.js'
-
npm Registry:
If your development workflow uses Node.js, you can install the qunit package from the npm Registry, using the
npm
CLI:npm install --save-dev qunit
Or, if using Yarn:
yarn add --dev qunit
You can then reference these in your HTML:
<link rel="stylesheet" href="./node_modules/qunit/qunit/qunit.css"> <script src="./node_modules/qunit/qunit/qunit.js"></script>
If your project uses an npm alternative 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).