Back to Qunit

Getting Started

docs/intro.md

2.25.05.9 KB
Original Source

In Node.js

Getting Started 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!

  1. QUnit.module: How to group related tests.
  2. QUnit.test: Define tests, How to wait for async code.
  3. Fixture feature: Keeping your DOM tests atomic.
  4. Step API: Testing asynchronous callbacks or event listeners.
  5. Assertions: Partial object comparison, expected exceptions, and much more.
  6. Browser: Productivity tricks, Browser automation, What can the toolbar do?
  7. CLI: Productivity tricks, Code coverage.
  8. Reporter API: Event emitter, Create your own reporter.
  9. Theme API: Create your own theme.

Compatibility

QUnit supports the following browsers and runtime environments:

<table> <thead> <tr><td></td><th>QUnit 1</th><th>QUnit&nbsp;2</th><th>QUnit&nbsp;3</th><th>QUnit 3 (ESM)</th></tr> </thead> <tbody> <tr><th>Internet Explorer</th><td>IE 6-11</td><td colspan=2>IE 9-11</td><td>&mdash;</td></tr> <tr><th>Edge</th><td>1+</td><td colspan=2>15+<sup><abbr title="both legacy MSEdge and Chromium-based Edge">[?]</abbr></sup></td><td>16+</td></tr> <tr><th>Firefox</th><td>3.6+</td><td colspan=2>45+</td><td>60+</td></tr> <tr><th>Safari</th><td>4.0+</td><td colspan=2>9.1+</td><td>10.1+</td></tr> <tr><th>Chrome</th><td>1+</td><td colspan=2>58+</td><td>61+</td></tr> <tr><th>Chrome Mobile</th><td>&mdash;</td><td colspan=2>49+ (Android 4.4+)</td><td>61+ (Android 7+)</td></tr> <tr><th>Opera</th><td>11+</td><td colspan=2>36+</td><td>48+</td></tr> <tr><th>Android Browser</th><td>2.3 - 5.0</td><td colspan=2>4.3 - 5.0</td><td>&mdash;</td></tr> <tr><th>iOS (Mobile Safari)</th><td>4.0+</td><td colspan=2>7.0+</td><td>10.3+</td></tr> <tr><th>PhantomJS</th><td colspan=2>1.x</td><td colspan=2>&mdash;</td></tr> <tr><th>Node.js</th><td>&mdash;</td><td>10+</td><td colspan=2>18+</td></tr> <tr><th>SpiderMonkey</th><td>&mdash;</td><td colspan=3>68+<sup><abbr title="since QUnit 2.14">[?]</abbr></sup></td></tr> </tbody> </table>

You can download QUnit 1.x and QUnit 2.x from the release archives.

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, or want to participate in sharing and discussing ideas, join us in the chat room on Matrix at #qunitjs_qunit:gitter.im:

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.


<span id="release-channels"></span>

Download

These are the official release channels for QUnit releases:

  • Download:

    You can save the qunit-2.25.0.js and qunit-2.25.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.

    bash
    curl -o qunit.css 'https://code.jquery.com/qunit/qunit-2.25.0.css'
    curl -o qunit.js 'https://code.jquery.com/qunit/qunit-2.25.0.js'
    
  • npm Registry:

    If your development workflow uses Node.js, you can install the qunit package from the npm Registry, using the npm CLI:

    bash
    npm install --save-dev qunit
    

    Or, if using Yarn:

    bash
    yarn add --dev qunit
    

    You can then reference these in your HTML:

    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 locate qunit/qunit/qunit.js and qunit/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