QUnit is a powerful, easy-to-use JavaScript testing framework. It was originally developed for the jQuery project and has since evolved to be a dependency of many modern JavaScript libraries and applications, including being the default testing framework for the Ember.js ecosystem.
+ +## Philosophy + +QUnit's philosophy as a test framework boils down to three primary tenants: _Easy_, _Universal_, and _Extensible_. + +### Easy + +QUnit should be easy-to-use from start to finish. Setting up your first test with should be super simple, requiring as little overhead as possible. Then, as you're developing, when a test or assertion fails, QUnit should provide feedback to you as fast as possible, with enough detail to quickly figure out the underlying issue. And it should do so without interrupting or corrupting other tests. + +Additionally, QUnit should be fast to make it easy for developers to have confidence that putting their tests on their critical path won't slow them down. + +### Univeral + +QUnit should be universally applicable for testing JavaScript code and support many different environments. JavaScript can run in the browser, in worker threads, and on the server, and so should QUnit so that you can test your code in the same environment where it will be running; the environment where you need to have confidence it works. + +### Extensible + +QUnit should be opinionated with a lean API to support being easy-to-use, yet highly extensible. There are many different approaches to testing and many different types of tests that users may want to write, and while we can not support all of these out of the box, we can support APIs to enable the community to extend QUnit to meet their needs. + +## Team + +Between API design, feature implementation, ticket triage, bug fixing, and everything else, there’s a lot of work that goes into QUnit, and all of it is done by volunteers. While we value all of our contributors, there are a few who contribute frequently, provide high-level direction for the project, and are responsible for its overall maintenance, and we recognize them below. + +For a full list of contributors, see the [authors list](https://github.com/qunitjs/qunit/blob/master/AUTHORS.txt). + +### [Timo Tijhof](https://timotijhof.net/) - Project Lead + +Timo is a senior engineer at [Wikimedia Foundation](https://www.wikimedia.org/) where he is on the [Architecture Committee](https://www.mediawiki.org/wiki/Architecture_committee), the technical committee that governs the integrity and stability of Wikimedia software projects. He has been contributing to jQuery Foundation projects since 2011, joined the QUnit Team in 2012, and became the project lead in mid-2020. + +### [Richard Gibson](https://twitter.com/gibson042) + +Richard is an architect at [Dyn](http://dyn.com/) in New Hampshire, USA. He has been contributing to jQuery Foundation projects since 2011 (QUnit since 2012) and can be spotted on a large handful of open source repositories. + +### [Trent Willis](https://twitter.com/trentmwillis) + +Trent is a Senior UI Engineer at [Netflix](https://www.netflix.com) in Los Gatos, CA. He has been contributing to QUnit since 2015 and served as the project lead from early 2017 to mid-2020. + +### [Jörn Zaefferer](http://bassistance.de/) + +Jörn is a freelance web developer, consultant, and trainer, residing in Cologne, Germany. Jörn evolved jQuery’s test suite into QUnit and was project lead until mid-2015. He created and maintains a number of popular plugins. As a jQuery UI development lead, he focuses on the development of new plugins, widgets, and utilities. + +### Previous Team Members + +* [James M. Greene](https://jamesmgreene.github.io/) +* [John Resig](https://johnresig.com/) +* [Kevin Partington](https://github.com/platinumazure) +* [Leo Balter](https://twitter.com/leobalter) +* [Scott González](http://nemikor.com/) + +## History + +QUnit was originally developed by John Resig as part of [jQuery](https://jquery.com/). In 2008 it got its own home, name, and API documentation, allowing others to use it for their unit testing as well. At the time it still depended on jQuery. A rewrite in 2009 fixed that and QUnit has been an independent project ever since. + +QUnit's assertion methods follow the [CommonJS Unit Testing](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) specification (which in turn was influenced by QUnit itself) and have since expanded to include a wider variety of assertions. diff --git a/docs/QUnit/hooks.md b/docs/api/QUnit/hooks.md similarity index 97% rename from docs/QUnit/hooks.md rename to docs/api/QUnit/hooks.md index 07976bcb0..3cf11c2b8 100644 --- a/docs/QUnit/hooks.md +++ b/docs/api/QUnit/hooks.md @@ -4,6 +4,8 @@ title: QUnit.hooks excerpt: Add global callbacks to run before or after each test. groups: - extension +redirect_from: + - "/QUnit/hooks/" version_added: "2.18.0" --- diff --git a/docs/QUnit/index.md b/docs/api/QUnit/index.md similarity index 65% rename from docs/QUnit/index.md rename to docs/api/QUnit/index.md index cb9d106e5..b351055c0 100644 --- a/docs/QUnit/index.md +++ b/docs/api/QUnit/index.md @@ -2,4 +2,6 @@ layout: group group: main title: Main methods +redirect_from: + - "/QUnit/" --- diff --git a/docs/QUnit/load.md b/docs/api/QUnit/load.md similarity index 98% rename from docs/QUnit/load.md rename to docs/api/QUnit/load.md index 8c226b480..07f1fa635 100644 --- a/docs/QUnit/load.md +++ b/docs/api/QUnit/load.md @@ -4,6 +4,8 @@ title: QUnit.load() excerpt: Inform the test runner that code has finished loading. groups: - deprecated +redirect_from: + - "/QUnit/load/" version_added: "1.0.0" version_deprecated: "unreleased" --- diff --git a/docs/QUnit/module.md b/docs/api/QUnit/module.md similarity index 99% rename from docs/QUnit/module.md rename to docs/api/QUnit/module.md index 3983d7ca3..66e5e1a45 100644 --- a/docs/QUnit/module.md +++ b/docs/api/QUnit/module.md @@ -6,6 +6,7 @@ groups: - main redirect_from: - "/QUnit.module/" + - "/QUnit/module/" - "/module/" version_added: "1.0.0" --- diff --git a/docs/QUnit/start.md b/docs/api/QUnit/start.md similarity index 93% rename from docs/QUnit/start.md rename to docs/api/QUnit/start.md index 97120ed3f..aa12966fc 100644 --- a/docs/QUnit/start.md +++ b/docs/api/QUnit/start.md @@ -6,6 +6,7 @@ groups: - main - async redirect_from: + - "/QUnit/start/" - "/start/" version_added: "1.0.0" --- @@ -25,5 +26,5 @@ See [`QUnit.config.autostart`](../config/autostart.md) for detailed examples of ## Changelog | [QUnit 2.1.1](https://github.com/qunitjs/qunit/releases/tag/2.1.1) | `QUnit.start()` no longer requires calling [`QUnit.load()`](./load.md) first. -| [QUnit 2.0](https://github.com/qunitjs/qunit/releases/tag/2.0.0) | Support for calling `start()` to resume an async test was removed. ([Migration guide](https://qunitjs.com/upgrade-guide-2.x/#introducing-assertasync)) +| [QUnit 2.0](https://github.com/qunitjs/qunit/releases/tag/2.0.0) | Support for calling `start()` to resume an async test was removed. ([Migration guide](../../upgrade-guide-2.x.md#introducing-assertasync)) | [QUnit 1.16](https://github.com/qunitjs/qunit/releases/tag/1.16.0) | Use of `start()` to resume an async test was deprecated in favour of [`assert.async()`](../assert/async.md). diff --git a/docs/QUnit/test.each.md b/docs/api/QUnit/test.each.md similarity index 98% rename from docs/QUnit/test.each.md rename to docs/api/QUnit/test.each.md index 7281400d4..07821922b 100644 --- a/docs/QUnit/test.each.md +++ b/docs/api/QUnit/test.each.md @@ -4,6 +4,8 @@ title: QUnit.test.each() excerpt: Add tests using a data provider. groups: - main +redirect_from: + - "/QUnit/test.each/" version_added: "2.16.0" --- diff --git a/docs/QUnit/test.md b/docs/api/QUnit/test.md similarity index 99% rename from docs/QUnit/test.md rename to docs/api/QUnit/test.md index ec82ec307..1275b75f5 100644 --- a/docs/QUnit/test.md +++ b/docs/api/QUnit/test.md @@ -8,6 +8,7 @@ groups: redirect_from: - "/QUnit.asyncTest/" - "/QUnit.test/" + - "/QUnit/test/" - "/asyncTest/" - "/test/" version_added: "1.0.0" diff --git a/docs/QUnit/test.only.md b/docs/api/QUnit/test.only.md similarity index 99% rename from docs/QUnit/test.only.md rename to docs/api/QUnit/test.only.md index 6713600a9..eb6cba7c3 100644 --- a/docs/QUnit/test.only.md +++ b/docs/api/QUnit/test.only.md @@ -7,6 +7,7 @@ groups: redirect_from: - "/QUnit.only/" - "/QUnit/only/" + - "/QUnit/test.only/" version_added: "1.20.0" --- diff --git a/docs/QUnit/test.skip.md b/docs/api/QUnit/test.skip.md similarity index 98% rename from docs/QUnit/test.skip.md rename to docs/api/QUnit/test.skip.md index 330b87a77..61da001ab 100644 --- a/docs/QUnit/test.skip.md +++ b/docs/api/QUnit/test.skip.md @@ -7,6 +7,7 @@ groups: redirect_from: - "/QUnit.skip/" - "/QUnit/skip/" + - "/QUnit/test.skip/" version_added: "1.16.0" --- diff --git a/docs/QUnit/test.todo.md b/docs/api/QUnit/test.todo.md similarity index 98% rename from docs/QUnit/test.todo.md rename to docs/api/QUnit/test.todo.md index e66b826ae..2dcb9a6ca 100644 --- a/docs/QUnit/test.todo.md +++ b/docs/api/QUnit/test.todo.md @@ -7,6 +7,7 @@ groups: redirect_from: - "/QUnit.todo/" - "/QUnit/todo/" + - "/QUnit/test.todo/" version_added: "2.2.0" --- diff --git a/docs/assert/async.md b/docs/api/assert/async.md similarity index 94% rename from docs/assert/async.md rename to docs/api/assert/async.md index a5110379d..cc1cb213f 100644 --- a/docs/assert/async.md +++ b/docs/api/assert/async.md @@ -6,6 +6,7 @@ groups: - assert - async redirect_from: + - "/assert/async/" - "/QUnit.stop/" - "/QUnit/stop/" - "/stop/" @@ -24,7 +25,7 @@ Instruct QUnit to wait for an asynchronous operation. ## See also -* [Migration guide](https://qunitjs.com/upgrade-guide-2.x/#introducing-assertasync) from QUnit 1.x `stop()` and `start()`. +* [Migration guide](../../upgrade-guide-2.x.md#introducing-assertasync) from QUnit 1.x `stop()` and `start()`. ## Examples diff --git a/docs/assert/deepEqual.md b/docs/api/assert/deepEqual.md similarity index 98% rename from docs/assert/deepEqual.md rename to docs/api/assert/deepEqual.md index 33946c7dd..c593498fa 100644 --- a/docs/assert/deepEqual.md +++ b/docs/api/assert/deepEqual.md @@ -5,6 +5,7 @@ excerpt: A recursive and strict comparison. groups: - assert redirect_from: + - "/assert/deepEqual/" - "/deepEqual/" version_added: "1.0.0" --- diff --git a/docs/assert/equal.md b/docs/api/assert/equal.md similarity index 98% rename from docs/assert/equal.md rename to docs/api/assert/equal.md index 3a9d9cdfc..5488fccc0 100644 --- a/docs/assert/equal.md +++ b/docs/api/assert/equal.md @@ -7,6 +7,7 @@ groups: redirect_from: - "/equal/" - "/equals/" + - "/assert/equal/" - "/assert/equals/" version_added: "1.0.0" --- diff --git a/docs/assert/expect.md b/docs/api/assert/expect.md similarity index 98% rename from docs/assert/expect.md rename to docs/api/assert/expect.md index 14c32a1df..707c3d13a 100644 --- a/docs/assert/expect.md +++ b/docs/api/assert/expect.md @@ -5,6 +5,7 @@ excerpt: Specify how many assertions are expected in a test. groups: - assert redirect_from: + - "/assert/expect/" - "/expect/" version_added: "1.0.0" --- diff --git a/docs/assert/false.md b/docs/api/assert/false.md similarity index 96% rename from docs/assert/false.md rename to docs/api/assert/false.md index 73ec0b5d1..ff690b913 100644 --- a/docs/assert/false.md +++ b/docs/api/assert/false.md @@ -4,6 +4,8 @@ title: assert.false() excerpt: A strict boolean false comparison. groups: - assert +redirect_from: + - "/assert/false/" version_added: "2.11.0" --- diff --git a/docs/assert/index.md b/docs/api/assert/index.md similarity index 96% rename from docs/assert/index.md rename to docs/api/assert/index.md index 68b5e913c..78571dfd3 100644 --- a/docs/assert/index.md +++ b/docs/api/assert/index.md @@ -5,6 +5,7 @@ title: Assertions amethyst: robots: index redirect_from: + - "/assert/" - "/QUnit.assert/" - "/category/assert/" --- diff --git a/docs/assert/notDeepEqual.md b/docs/api/assert/notDeepEqual.md similarity index 97% rename from docs/assert/notDeepEqual.md rename to docs/api/assert/notDeepEqual.md index 4e315d0eb..f6feeef18 100644 --- a/docs/assert/notDeepEqual.md +++ b/docs/api/assert/notDeepEqual.md @@ -5,6 +5,7 @@ excerpt: An inverted deep equal comparison. groups: - assert redirect_from: + - "/assert/notDeepEqual/" - "/notDeepEqual/" version_added: "1.0.0" --- diff --git a/docs/assert/notEqual.md b/docs/api/assert/notEqual.md similarity index 98% rename from docs/assert/notEqual.md rename to docs/api/assert/notEqual.md index b16bb4bab..41155f116 100644 --- a/docs/assert/notEqual.md +++ b/docs/api/assert/notEqual.md @@ -5,6 +5,7 @@ excerpt: A loose inequality comparison. groups: - assert redirect_from: + - "/assert/notEqual/" - "/notEqual/" version_added: "1.0.0" --- diff --git a/docs/assert/notOk.md b/docs/api/assert/notOk.md similarity index 97% rename from docs/assert/notOk.md rename to docs/api/assert/notOk.md index cd721b794..a8bcf9dfb 100644 --- a/docs/assert/notOk.md +++ b/docs/api/assert/notOk.md @@ -5,6 +5,7 @@ excerpt: Check if the first argument is falsy. groups: - assert redirect_from: + - "/assert/notOk/" - "/notOk/" version_added: "1.18.0" --- diff --git a/docs/assert/notPropContains.md b/docs/api/assert/notPropContains.md similarity index 97% rename from docs/assert/notPropContains.md rename to docs/api/assert/notPropContains.md index 12f7edfa9..1384d7f02 100644 --- a/docs/assert/notPropContains.md +++ b/docs/api/assert/notPropContains.md @@ -4,6 +4,8 @@ title: assert.notPropContains() excerpt: Check that an object does not contain certain properties. groups: - assert +redirect_from: + - "/assert/notPropContains/" version_added: "2.18.0" --- diff --git a/docs/assert/notPropEqual.md b/docs/api/assert/notPropEqual.md similarity index 98% rename from docs/assert/notPropEqual.md rename to docs/api/assert/notPropEqual.md index 7ec9bc0cb..5e70768fd 100644 --- a/docs/assert/notPropEqual.md +++ b/docs/api/assert/notPropEqual.md @@ -5,6 +5,7 @@ excerpt: Compare an object's own properties for inequality. groups: - assert redirect_from: + - "/assert/notPropEqual/" - "/notPropEqual/" version_added: "1.11.0" --- diff --git a/docs/assert/notStrictEqual.md b/docs/api/assert/notStrictEqual.md similarity index 97% rename from docs/assert/notStrictEqual.md rename to docs/api/assert/notStrictEqual.md index f0c6837b5..201ad58fd 100644 --- a/docs/assert/notStrictEqual.md +++ b/docs/api/assert/notStrictEqual.md @@ -5,6 +5,7 @@ excerpt: A strict comparison, checking for inequality. groups: - assert redirect_from: + - "/assert/notStrictEqual/" - "/notStrictEqual/" version_added: "1.0.0" --- diff --git a/docs/assert/ok.md b/docs/api/assert/ok.md similarity index 98% rename from docs/assert/ok.md rename to docs/api/assert/ok.md index a375ce5b5..f12592ed2 100644 --- a/docs/assert/ok.md +++ b/docs/api/assert/ok.md @@ -5,6 +5,7 @@ excerpt: Check if the first argument is truthy. groups: - assert redirect_from: + - "/assert/ok/" - "/ok/" version_added: "1.0.0" --- diff --git a/docs/assert/propContains.md b/docs/api/assert/propContains.md similarity index 97% rename from docs/assert/propContains.md rename to docs/api/assert/propContains.md index 92f4f2364..05bebe3f1 100644 --- a/docs/assert/propContains.md +++ b/docs/api/assert/propContains.md @@ -4,6 +4,8 @@ title: assert.propContains() excerpt: Check that an object contains certain properties. groups: - assert +redirect_from: + - "/assert/propContains/" version_added: "2.18.0" --- diff --git a/docs/assert/propEqual.md b/docs/api/assert/propEqual.md similarity index 98% rename from docs/assert/propEqual.md rename to docs/api/assert/propEqual.md index ef16ccb76..c902075cc 100644 --- a/docs/assert/propEqual.md +++ b/docs/api/assert/propEqual.md @@ -5,6 +5,7 @@ excerpt: Compare an object's own properties. groups: - assert redirect_from: + - "/assert/propEqual/" - "/propEqual/" version_added: "1.11.0" --- diff --git a/docs/assert/pushResult.md b/docs/api/assert/pushResult.md similarity index 98% rename from docs/assert/pushResult.md rename to docs/api/assert/pushResult.md index 53cbb14aa..886095c44 100644 --- a/docs/assert/pushResult.md +++ b/docs/api/assert/pushResult.md @@ -4,6 +4,8 @@ title: assert.pushResult() excerpt: Report the result of a custom assertion. groups: - assert +redirect_from: + - "/assert/pushResult/" version_added: "1.22.0" --- diff --git a/docs/assert/rejects.md b/docs/api/assert/rejects.md similarity index 98% rename from docs/assert/rejects.md rename to docs/api/assert/rejects.md index 907f5dc4c..6821fe4af 100644 --- a/docs/assert/rejects.md +++ b/docs/api/assert/rejects.md @@ -4,6 +4,8 @@ title: assert.rejects() excerpt: Test if the provided promise rejects. groups: - assert +redirect_from: + - "/assert/rejects/" version_added: "2.5.0" --- diff --git a/docs/assert/step.md b/docs/api/assert/step.md similarity index 97% rename from docs/assert/step.md rename to docs/api/assert/step.md index 913425cfd..24e318e7c 100644 --- a/docs/assert/step.md +++ b/docs/api/assert/step.md @@ -4,6 +4,8 @@ title: assert.step() excerpt: Record a step for later verification. groups: - assert +redirect_from: + - "/assert/step/" version_added: "2.2.0" --- diff --git a/docs/assert/strictEqual.md b/docs/api/assert/strictEqual.md similarity index 97% rename from docs/assert/strictEqual.md rename to docs/api/assert/strictEqual.md index 2d2e1cd76..bb6890456 100644 --- a/docs/assert/strictEqual.md +++ b/docs/api/assert/strictEqual.md @@ -8,6 +8,7 @@ redirect_from: - "/same/" - "/strictEqual/" - "/assert/same/" + - "/assert/strictEqual/" version_added: "1.0.0" --- diff --git a/docs/assert/throws.md b/docs/api/assert/throws.md similarity index 99% rename from docs/assert/throws.md rename to docs/api/assert/throws.md index 3416bd70b..f854eb1fb 100644 --- a/docs/assert/throws.md +++ b/docs/api/assert/throws.md @@ -6,6 +6,7 @@ groups: - assert redirect_from: - "/assert/raises/" + - "/assert/throws/" - "/throws/" version_added: "1.0.0" --- diff --git a/docs/assert/timeout.md b/docs/api/assert/timeout.md similarity index 97% rename from docs/assert/timeout.md rename to docs/api/assert/timeout.md index d3bb10365..82753101d 100644 --- a/docs/assert/timeout.md +++ b/docs/api/assert/timeout.md @@ -5,6 +5,8 @@ excerpt: How long to wait for async operations. groups: - assert - async +redirect_from: + - "/assert/timeout/" version_added: "2.4.0" --- diff --git a/docs/assert/true.md b/docs/api/assert/true.md similarity index 96% rename from docs/assert/true.md rename to docs/api/assert/true.md index 725822d49..5ee7ce94b 100644 --- a/docs/assert/true.md +++ b/docs/api/assert/true.md @@ -4,6 +4,8 @@ title: assert.true() excerpt: A strict boolean true comparison. groups: - assert +redirect_from: + - "/assert/true/" version_added: "2.11.0" --- diff --git a/docs/assert/verifySteps.md b/docs/api/assert/verifySteps.md similarity index 99% rename from docs/assert/verifySteps.md rename to docs/api/assert/verifySteps.md index 49fbf9380..e1a8dc2b7 100644 --- a/docs/assert/verifySteps.md +++ b/docs/api/assert/verifySteps.md @@ -4,6 +4,8 @@ title: assert.verifySteps() excerpt: Verify the exact order of steps. groups: - assert +redirect_from: + - "/assert/verifySteps/" version_added: "2.2.0" --- diff --git a/docs/async.md b/docs/api/async.md similarity index 65% rename from docs/async.md rename to docs/api/async.md index 93079b720..90dcb4b89 100644 --- a/docs/async.md +++ b/docs/api/async.md @@ -2,4 +2,6 @@ layout: group group: async title: Async control +redirect_from: + - "/async/" --- diff --git a/docs/callbacks/QUnit.begin.md b/docs/api/callbacks/QUnit.begin.md similarity index 98% rename from docs/callbacks/QUnit.begin.md rename to docs/api/callbacks/QUnit.begin.md index c85308a25..ba8bb75ab 100644 --- a/docs/callbacks/QUnit.begin.md +++ b/docs/api/callbacks/QUnit.begin.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire when the test run begins. groups: - callbacks redirect_from: + - "/callbacks/QUnit.begin/" - "/QUnit.begin/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.done.md b/docs/api/callbacks/QUnit.done.md similarity index 98% rename from docs/callbacks/QUnit.done.md rename to docs/api/callbacks/QUnit.done.md index b11ba9254..cc717728e 100644 --- a/docs/callbacks/QUnit.done.md +++ b/docs/api/callbacks/QUnit.done.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire when the test run has ended. groups: - callbacks redirect_from: + - "/callbacks/QUnit.done/" - "/QUnit.done/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.log.md b/docs/api/callbacks/QUnit.log.md similarity index 98% rename from docs/callbacks/QUnit.log.md rename to docs/api/callbacks/QUnit.log.md index cba185f1c..c9ae32b1d 100644 --- a/docs/callbacks/QUnit.log.md +++ b/docs/api/callbacks/QUnit.log.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire whenever an assertion completes. groups: - callbacks redirect_from: + - "/callbacks/QUnit.log/" - "/QUnit.log/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.moduleDone.md b/docs/api/callbacks/QUnit.moduleDone.md similarity index 97% rename from docs/callbacks/QUnit.moduleDone.md rename to docs/api/callbacks/QUnit.moduleDone.md index 2dfa2440f..61867a9f0 100644 --- a/docs/callbacks/QUnit.moduleDone.md +++ b/docs/api/callbacks/QUnit.moduleDone.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire whenever a module ends. groups: - callbacks redirect_from: + - "/callbacks/QUnit.moduleDone/" - "/QUnit.moduleDone/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.moduleStart.md b/docs/api/callbacks/QUnit.moduleStart.md similarity index 95% rename from docs/callbacks/QUnit.moduleStart.md rename to docs/api/callbacks/QUnit.moduleStart.md index 3a55410ca..967e8d8e1 100644 --- a/docs/callbacks/QUnit.moduleStart.md +++ b/docs/api/callbacks/QUnit.moduleStart.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire whenever a module begins. groups: - callbacks redirect_from: + - "/callbacks/QUnit.moduleStart/" - "/QUnit.moduleStart/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.on.md b/docs/api/callbacks/QUnit.on.md similarity index 99% rename from docs/callbacks/QUnit.on.md rename to docs/api/callbacks/QUnit.on.md index b828cdfee..fe8282cb2 100644 --- a/docs/callbacks/QUnit.on.md +++ b/docs/api/callbacks/QUnit.on.md @@ -4,6 +4,8 @@ title: QUnit.on() excerpt: Register a callback to fire whenever the specified event is emitted. groups: - callbacks +redirect_from: + - "/callbacks/QUnit.on/" version_added: "2.2.0" --- diff --git a/docs/callbacks/QUnit.testDone.md b/docs/api/callbacks/QUnit.testDone.md similarity index 98% rename from docs/callbacks/QUnit.testDone.md rename to docs/api/callbacks/QUnit.testDone.md index c7e424790..f2119895b 100644 --- a/docs/callbacks/QUnit.testDone.md +++ b/docs/api/callbacks/QUnit.testDone.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire whenever a test ends. groups: - callbacks redirect_from: + - "/callbacks/QUnit.testDone/" - "/QUnit.testDone/" version_added: "1.0.0" --- diff --git a/docs/callbacks/QUnit.testStart.md b/docs/api/callbacks/QUnit.testStart.md similarity index 96% rename from docs/callbacks/QUnit.testStart.md rename to docs/api/callbacks/QUnit.testStart.md index 0fee169d1..b26af2003 100644 --- a/docs/callbacks/QUnit.testStart.md +++ b/docs/api/callbacks/QUnit.testStart.md @@ -5,6 +5,7 @@ excerpt: Register a callback to fire whenever a test begins. groups: - callbacks redirect_from: + - "/callbacks/QUnit.testStart/" - "/QUnit.testStart/" version_added: "1.0.0" --- diff --git a/docs/callbacks/index.md b/docs/api/callbacks/index.md similarity index 85% rename from docs/callbacks/index.md rename to docs/api/callbacks/index.md index 1e154dc89..89412aa15 100644 --- a/docs/callbacks/index.md +++ b/docs/api/callbacks/index.md @@ -3,5 +3,6 @@ layout: group group: callbacks title: Callback events redirect_from: + - "/callbacks/" - "/category/callbacks/" --- diff --git a/docs/config/altertitle.md b/docs/api/config/altertitle.md similarity index 93% rename from docs/config/altertitle.md rename to docs/api/config/altertitle.md index 321178a25..08ab47d0e 100644 --- a/docs/config/altertitle.md +++ b/docs/api/config/altertitle.md @@ -4,6 +4,8 @@ title: QUnit.config.altertitle excerpt: Insert a success or failure symbol in the document title (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.altertitle/" version_added: "1.0.0" --- diff --git a/docs/config/autostart.md b/docs/api/config/autostart.md similarity index 97% rename from docs/config/autostart.md rename to docs/api/config/autostart.md index 8a0749299..d6479e9d4 100644 --- a/docs/config/autostart.md +++ b/docs/api/config/autostart.md @@ -4,6 +4,8 @@ title: QUnit.config.autostart excerpt: Control when the test run may start. groups: - config +redirect_from: + - "/config/QUnit.config.autostart/" version_added: "1.0.0" --- diff --git a/docs/config/collapse.md b/docs/api/config/collapse.md similarity index 92% rename from docs/config/collapse.md rename to docs/api/config/collapse.md index dd50e5103..998f218e2 100644 --- a/docs/config/collapse.md +++ b/docs/api/config/collapse.md @@ -4,6 +4,8 @@ title: QUnit.config.collapse excerpt: Collapse the details of failing tests after the first one (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.collapse/" version_added: "1.0.0" --- diff --git a/docs/config/current.md b/docs/api/config/current.md similarity index 94% rename from docs/config/current.md rename to docs/api/config/current.md index 505c54d78..978ff4e29 100644 --- a/docs/config/current.md +++ b/docs/api/config/current.md @@ -5,6 +5,8 @@ excerpt: Internal object representing the currently running test. groups: - config - extension +redirect_from: + - "/config/QUnit.config.current/" version_added: "1.0.0" --- diff --git a/docs/config/failOnZeroTests.md b/docs/api/config/failOnZeroTests.md similarity index 90% rename from docs/config/failOnZeroTests.md rename to docs/api/config/failOnZeroTests.md index fb3302541..26e1d7333 100644 --- a/docs/config/failOnZeroTests.md +++ b/docs/api/config/failOnZeroTests.md @@ -4,6 +4,8 @@ title: QUnit.config.failOnZeroTests excerpt: Fail the test run if no tests were run. groups: - config +redirect_from: + - "/config/QUnit.config.failOnZeroTests/" version_added: "2.16.0" --- diff --git a/docs/config/filter.md b/docs/api/config/filter.md similarity index 87% rename from docs/config/filter.md rename to docs/api/config/filter.md index d87f94d59..ec0a773cd 100644 --- a/docs/config/filter.md +++ b/docs/api/config/filter.md @@ -4,6 +4,8 @@ title: QUnit.config.filter excerpt: Select tests to run based on a substring or pattern match. groups: - config +redirect_from: + - "/config/QUnit.config.filter/" version_added: "1.0.0" --- @@ -20,7 +22,11 @@ Select tests to run based on a substring or pattern match. -This option is available as [CLI option](https://qunitjs.com/cli/), as control in the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser), and supported as URL query parameter.
++ +This option is available as [CLI option](../../cli.md), as control in the [HTML Reporter](../../intro.md#in-the-browser), and supported as URL query parameter. + +
QUnit only runs tests of which the module name or test name are a case-insensitive substring match for the filter string. You can invert the filter by prefixing an exclamation mark (`!`) to the string, in which case we skip the matched tests, and run the tests that don't match the filter. diff --git a/docs/config/fixture.md b/docs/api/config/fixture.md similarity index 100% rename from docs/config/fixture.md rename to docs/api/config/fixture.md diff --git a/docs/config/hidepassed.md b/docs/api/config/hidepassed.md similarity index 83% rename from docs/config/hidepassed.md rename to docs/api/config/hidepassed.md index 8bdcf5d7b..1a5d6166a 100644 --- a/docs/config/hidepassed.md +++ b/docs/api/config/hidepassed.md @@ -4,6 +4,8 @@ title: QUnit.config.hidepassed excerpt: Hide results of passed tests (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.hidepassed/" version_added: "1.0.0" --- @@ -20,6 +22,6 @@ In the HTML Reporter, hide results of passed tests. -This option can also be controlled via the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser).
+This option can also be controlled via the [HTML Reporter](../../intro.md#in-the-browser).
By default, the HTML Reporter will list (in collapsed form) the names of all passed tests. Enable this option, to only list failing tests. diff --git a/docs/config/index.md b/docs/api/config/index.md similarity index 98% rename from docs/config/index.md rename to docs/api/config/index.md index bf291e48c..9aac9d26c 100644 --- a/docs/config/index.md +++ b/docs/api/config/index.md @@ -3,8 +3,9 @@ layout: group group: config title: QUnit.config redirect_from: - - "/QUnit.config/" + - "/config/" - "/config/QUnit.config/" + - "/QUnit.config/" --- General configuration options for QUnit. diff --git a/docs/config/maxDepth.md b/docs/api/config/maxDepth.md similarity index 91% rename from docs/config/maxDepth.md rename to docs/api/config/maxDepth.md index 197f6ee75..7e9836646 100644 --- a/docs/config/maxDepth.md +++ b/docs/api/config/maxDepth.md @@ -4,6 +4,8 @@ title: QUnit.config.maxDepth excerpt: The depth up-to which an object will be serialized during a diff (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.maxDepth/" version_added: "1.16.0" --- diff --git a/docs/config/module.md b/docs/api/config/module.md similarity index 95% rename from docs/config/module.md rename to docs/api/config/module.md index 6d698531f..79c36a115 100644 --- a/docs/config/module.md +++ b/docs/api/config/module.md @@ -4,6 +4,8 @@ title: QUnit.config.module excerpt: Select a single test module to run. groups: - config +redirect_from: + - "/config/QUnit.config.module/" version_added: "1.8.0" --- diff --git a/docs/config/moduleId.md b/docs/api/config/moduleId.md similarity index 86% rename from docs/config/moduleId.md rename to docs/api/config/moduleId.md index fa9edafdb..659af9379 100644 --- a/docs/config/moduleId.md +++ b/docs/api/config/moduleId.md @@ -4,6 +4,8 @@ title: QUnit.config.moduleId excerpt: Select one or more modules to run, by their internal ID (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.moduleId/" version_added: "1.23.0" --- @@ -20,7 +22,7 @@ In the HTML Reporter, select one or more modules to run by their internal ID. -This option can be controlled via the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser) interface.
+This option can be controlled via the [HTML Reporter](../../intro.md#in-the-browser) interface.
Specify modules by their internally hashed identifier for a given module. You can specify one or multiple modules to run. This option powers the multi-select dropdown menu in the HTML Reporter. diff --git a/docs/config/modules.md b/docs/api/config/modules.md similarity index 95% rename from docs/config/modules.md rename to docs/api/config/modules.md index c9edc44ce..ac0c6eb7c 100644 --- a/docs/config/modules.md +++ b/docs/api/config/modules.md @@ -5,6 +5,8 @@ excerpt: List of defined test modules. groups: - config - extension +redirect_from: + - "/config/QUnit.config.modules/" version_added: "1.16.0" --- diff --git a/docs/config/noglobals.md b/docs/api/config/noglobals.md similarity index 87% rename from docs/config/noglobals.md rename to docs/api/config/noglobals.md index 01e7c63bc..d1338fa7d 100644 --- a/docs/config/noglobals.md +++ b/docs/api/config/noglobals.md @@ -4,6 +4,8 @@ title: QUnit.config.noglobals excerpt: Check the global object after each test and report new properties as failures. groups: - config +redirect_from: + - "/config/QUnit.config.noglobals/" version_added: "1.0.0" --- @@ -22,4 +24,4 @@ Check the global object after each test and report new properties as failures. Enable this option to let QUnit keep track of which global variables and properties exist on the global object (e.g. `window` in browsers). When new global properties are found, they will result in test failures to you make sure your application and your tests are not leaking any state. -This option can also be controlled via the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser) interface.
+This option can also be controlled via the [HTML Reporter](../../intro.md#in-the-browser).
diff --git a/docs/config/notrycatch.md b/docs/api/config/notrycatch.md similarity index 81% rename from docs/config/notrycatch.md rename to docs/api/config/notrycatch.md index 32a2a6d15..5d57500d7 100644 --- a/docs/config/notrycatch.md +++ b/docs/api/config/notrycatch.md @@ -4,6 +4,8 @@ title: QUnit.config.notrycatch excerpt: Disable handling of uncaught exceptions during tests. groups: - config +redirect_from: + - "/config/QUnit.config.notrycatch/" version_added: "1.0.0" --- @@ -20,7 +22,7 @@ Disable handling of uncaught exceptions during tests. -This option can also be controlled via the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser) interface, and is supported as URL query parameter.
+This option can also be controlled via the [HTML Reporter](../../intro.md#in-the-browser) interface, and is supported as URL query parameter.
By default, QUnit handles uncaught exceptions during test execution and reports them as test failures. This lets other tests continue running and allows reporters to summarise results. diff --git a/docs/config/reorder.md b/docs/api/config/reorder.md similarity index 94% rename from docs/config/reorder.md rename to docs/api/config/reorder.md index d329effde..dc7edb74f 100644 --- a/docs/config/reorder.md +++ b/docs/api/config/reorder.md @@ -4,6 +4,8 @@ title: QUnit.config.reorder excerpt: Allow re-running of previously failed tests out of order. groups: - config +redirect_from: + - "/config/QUnit.config.reorder/" version_added: "1.0.0" --- diff --git a/docs/config/requireExpects.md b/docs/api/config/requireExpects.md similarity index 89% rename from docs/config/requireExpects.md rename to docs/api/config/requireExpects.md index 10b04117e..55e298837 100644 --- a/docs/config/requireExpects.md +++ b/docs/api/config/requireExpects.md @@ -4,6 +4,8 @@ title: QUnit.config.requireExpects excerpt: Fail tests that don't specify how many assertions they expect. groups: - config +redirect_from: + - "/config/QUnit.config.requireExpects/" version_added: "1.7.0" --- diff --git a/docs/config/scrolltop.md b/docs/api/config/scrolltop.md similarity index 92% rename from docs/config/scrolltop.md rename to docs/api/config/scrolltop.md index bfa3162ea..884430ac3 100644 --- a/docs/config/scrolltop.md +++ b/docs/api/config/scrolltop.md @@ -4,6 +4,8 @@ title: QUnit.config.scrolltop excerpt: Scroll to the top of the page after the test run (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.scrolltop/" version_added: "1.14.0" --- diff --git a/docs/config/seed.md b/docs/api/config/seed.md similarity index 91% rename from docs/config/seed.md rename to docs/api/config/seed.md index a252a769c..5448bbfa5 100644 --- a/docs/config/seed.md +++ b/docs/api/config/seed.md @@ -4,6 +4,8 @@ title: QUnit.config.seed excerpt: Enable randomized ordering of tests. groups: - config +redirect_from: + - "/config/QUnit.config.seed/" version_added: "1.23.0" --- @@ -20,7 +22,7 @@ Enable randomized ordering of tests. -This option is also available as [CLI option](https://qunitjs.com/cli/), and as URL query parameter in the browser.
+This option is also available as [CLI option](../../cli.md), and as URL query parameter in the browser.
When set to boolean true, or a string, QUnit will run tests in a [seeded-random order](https://en.wikipedia.org/wiki/Random_seed). diff --git a/docs/config/storage.md b/docs/api/config/storage.md similarity index 94% rename from docs/config/storage.md rename to docs/api/config/storage.md index 934268f63..85c31e831 100644 --- a/docs/config/storage.md +++ b/docs/api/config/storage.md @@ -4,6 +4,8 @@ title: QUnit.config.storage excerpt: The Storage object to use for remembering failed tests between runs. groups: - config +redirect_from: + - "/config/QUnit.config.storage/" version_added: "2.1.0" --- diff --git a/docs/config/testId.md b/docs/api/config/testId.md similarity index 86% rename from docs/config/testId.md rename to docs/api/config/testId.md index 453e6c659..0275b81e3 100644 --- a/docs/config/testId.md +++ b/docs/api/config/testId.md @@ -4,6 +4,8 @@ title: QUnit.config.testId excerpt: Select one or more tests to run, by their internal ID (HTML Reporter). groups: - config +redirect_from: + - "/config/QUnit.config.testId/" version_added: "1.16.0" --- @@ -20,7 +22,7 @@ In the HTML Reporter, select one or more tests to run by their internal ID. -This option can be controlled via the [HTML Reporter](https://qunitjs.com/intro/#in-the-browser) interface.
+This option can be controlled via the [HTML Reporter](../../intro.md#in-the-browser) interface.
This property allows QUnit to run specific tests by their internally hashed identifier. You can specify one or multiple tests to run. This option powers the "Rerun" button in the HTML Reporter. diff --git a/docs/config/testTimeout.md b/docs/api/config/testTimeout.md similarity index 93% rename from docs/config/testTimeout.md rename to docs/api/config/testTimeout.md index de1df8e51..157aa71f1 100644 --- a/docs/config/testTimeout.md +++ b/docs/api/config/testTimeout.md @@ -4,6 +4,8 @@ title: QUnit.config.testTimeout excerpt: Set a global default timeout after which a test will fail. groups: - config +redirect_from: + - "/config/QUnit.config.testTimeout/" version_added: "1.0.0" --- diff --git a/docs/config/urlConfig.md b/docs/api/config/urlConfig.md similarity index 98% rename from docs/config/urlConfig.md rename to docs/api/config/urlConfig.md index 3f5ccd809..4c0533e6d 100644 --- a/docs/config/urlConfig.md +++ b/docs/api/config/urlConfig.md @@ -5,6 +5,8 @@ excerpt: Register additional input fields in the toolbar (HTML Reporter). groups: - config - extension +redirect_from: + - "/config/QUnit.config.urlConfig/" version_added: "1.0.0" --- diff --git a/docs/deprecated.md b/docs/api/deprecated.md similarity index 66% rename from docs/deprecated.md rename to docs/api/deprecated.md index a56779b9f..cae4b1734 100644 --- a/docs/deprecated.md +++ b/docs/api/deprecated.md @@ -2,4 +2,6 @@ layout: group group: deprecated title: Deprecated methods +redirect_from: + - "/deprecated/" --- diff --git a/docs/extension/QUnit.assert.md b/docs/api/extension/QUnit.assert.md similarity index 95% rename from docs/extension/QUnit.assert.md rename to docs/api/extension/QUnit.assert.md index c48c4fc4c..7044291c2 100644 --- a/docs/extension/QUnit.assert.md +++ b/docs/api/extension/QUnit.assert.md @@ -6,6 +6,7 @@ groups: - extension redirect_from: - "/config/QUnit.assert/" + - "/extension/QUnit.assert/" version_added: "1.7.0" --- diff --git a/docs/extension/QUnit.dump.parse.md b/docs/api/extension/QUnit.dump.parse.md similarity index 98% rename from docs/extension/QUnit.dump.parse.md rename to docs/api/extension/QUnit.dump.parse.md index c5cf61bfc..5aa6b7fb8 100644 --- a/docs/extension/QUnit.dump.parse.md +++ b/docs/api/extension/QUnit.dump.parse.md @@ -8,6 +8,7 @@ redirect_from: - "/QUnit.dump.parse/" - "/QUnit.jsDump.parse/" - "/config/QUnit.dump.parse/" + - "/extension/QUnit.dump.parse/" version_added: "1.0.0" --- diff --git a/docs/extension/QUnit.extend.md b/docs/api/extension/QUnit.extend.md similarity index 97% rename from docs/extension/QUnit.extend.md rename to docs/api/extension/QUnit.extend.md index dad6fac8e..f804335ea 100644 --- a/docs/extension/QUnit.extend.md +++ b/docs/api/extension/QUnit.extend.md @@ -7,6 +7,7 @@ groups: - deprecated redirect_from: - "/config/QUnit.extend/" + - "/extension/QUnit.extend/" version_added: "1.0.0" version_deprecated: "2.12.0" --- diff --git a/docs/extension/QUnit.onUncaughtException.md b/docs/api/extension/QUnit.onUncaughtException.md similarity index 94% rename from docs/extension/QUnit.onUncaughtException.md rename to docs/api/extension/QUnit.onUncaughtException.md index f4adc512f..0bbe50500 100644 --- a/docs/extension/QUnit.onUncaughtException.md +++ b/docs/api/extension/QUnit.onUncaughtException.md @@ -7,6 +7,7 @@ groups: version_added: "2.17.0" redirect_from: - "/config/QUnit.onUncaughtException/" + - "/extension/QUnit.onUncaughtException/" --- `QUnit.onUncaughtException( error )` diff --git a/docs/extension/QUnit.push.md b/docs/api/extension/QUnit.push.md similarity index 97% rename from docs/extension/QUnit.push.md rename to docs/api/extension/QUnit.push.md index 8e28f16d5..eb2499171 100644 --- a/docs/extension/QUnit.push.md +++ b/docs/api/extension/QUnit.push.md @@ -7,6 +7,7 @@ groups: - deprecated redirect_from: - "/config/QUnit.push/" + - "/extension/QUnit.push/" version_added: "1.0.0" version_deprecated: "2.1.0" --- diff --git a/docs/extension/QUnit.stack.md b/docs/api/extension/QUnit.stack.md similarity index 97% rename from docs/extension/QUnit.stack.md rename to docs/api/extension/QUnit.stack.md index 9c0e10986..4eb094ccd 100644 --- a/docs/extension/QUnit.stack.md +++ b/docs/api/extension/QUnit.stack.md @@ -6,6 +6,7 @@ groups: - extension redirect_from: - "/config/QUnit.stack/" + - "/extension/QUnit.stack/" version_added: "1.19.0" --- diff --git a/docs/extension/index.md b/docs/api/extension/index.md similarity index 66% rename from docs/extension/index.md rename to docs/api/extension/index.md index 63d73e68a..c5d63cfbc 100644 --- a/docs/extension/index.md +++ b/docs/api/extension/index.md @@ -2,4 +2,6 @@ layout: group group: extension title: Extension interface +redirect_from: + - "/extension/" --- diff --git a/docs/api/index.md b/docs/api/index.md new file mode 100644 index 000000000..6df12483d --- /dev/null +++ b/docs/api/index.md @@ -0,0 +1,23 @@ +--- +layout: page-api +title: QUnit API +excerpt: API reference documentation for QUnit. +amethyst: + prepend_description_heading: false +redirect_from: + - "/category/all/" +--- + +QUnit is a powerful, easy-to-use JavaScript unit test suite. + +If you're new to QUnit, check out [Getting Started](../intro.md). + +QUnit has no dependencies and supports Node.js, SpiderMonkey, and all [major browsers](../intro.md#in-the-browser). + + + +* [Main methods](./QUnit/) +* [Assertions](./assert/) +* [Callback events](./callbacks/) +* [Configuration options](./config/) +* [Extension interface](./extension/) diff --git a/docs/removed.md b/docs/api/removed.md similarity index 65% rename from docs/removed.md rename to docs/api/removed.md index d76f152e9..9dafa6714 100644 --- a/docs/removed.md +++ b/docs/api/removed.md @@ -2,4 +2,6 @@ layout: group group: removed title: Removed methods +redirect_from: + - "/removed/" --- diff --git a/docs/brand.md b/docs/brand.md new file mode 100644 index 000000000..87172533f --- /dev/null +++ b/docs/brand.md @@ -0,0 +1,85 @@ +--- +layout: page +title: Brand guidelines +amethyst: + toc: true +--- + +## Brand colors + +* QUnit Primary Purple `#9C3493` +* QUnit Secondary Purple `#390F39` + +
+
+**QUnit Primary Purple**
+HEX: #9C3493
+CMYK: 0 67 6 39
+RGB: 156 52 147
+Pantone: 253
+
+
+
+**QUnit Secondary Purple**
+HEX: #390F39
+CMYK: 0 74 0 78
+RGB: 57 15 57
+Pantone: 229
+
+
+ +How to use the QUnit CLI (command-line interface), after [installing it from npm](./intro.md#in-nodejs). + +
+ +## QUnit CLI options + +``` +Usage: qunit [options] [files] + + Files should be a space-separated list of files, directories, or glob expressions. + Defaults to 'test/**/*.js'. + +Options: + -V, --version output the version number + -f, --filterEasy, zero configuration setup for any Node.js project and minimal configuration for Browser-based projects.
+Tests can be run anywhere; Node, your browser, even inside a Web Worker. Test your code where it runs.
+Flexible APIs for custom assertions, runners, and reporters mean you can extend QUnit to fit your needs.
+v2.20.1 (changelog)
+ +These are the officially supported [release channels](intro.md#release-channels) for QUnit: + +* CDN: [`qunit-2.20.1.js`](https://code.jquery.com/qunit/qunit-2.20.1.js) and [`qunit-2.20.1.css`](https://code.jquery.com/qunit/qunit-2.20.1.css) +* npm: `npm install --save-dev qunit` +* Yarn: `yarn add --dev qunit` +* Bower: `bower install --save-dev qunit` + +--- + +## Join the Community + +Join us on [Mastodon](https://fosstodon.org/@qunit), [Twitter](https://twitter.com/qunitjs), or [Gitter chat](https://gitter.im/qunitjs/qunit).
+ +To contribute: + +* [Watch the repository](https://github.com/qunitjs/qunit) to learn about release, new requests, or bug reports. +* The source of this website, is in the ["docs/" directory](https://github.com/qunitjs/qunit/tree/master/docs). + +--- + +What are you waiting for? Get started!
diff --git a/docs/intro.md b/docs/intro.md new file mode 100644 index 000000000..18d71554a --- /dev/null +++ b/docs/intro.md @@ -0,0 +1,225 @@ +--- +layout: page +title: Getting Started +amethyst: + toc: true +redirect_from: + - "/guides/" + - "/cookbook/" +--- + ++ +The following guide will get you up-and-running with QUnit either in Node.js or [in the Browser](#in-the-browser). + +
+ +## In Node.js + +Getting started with QUnit for Node.js projects is quick and easy. First, install the [qunit](https://www.npmjs.com/package/qunit) package using `npm`: + +```bash +npm install --save-dev qunit + +# Or, if using Yarn: +yarn add --dev qunit +``` + +Let's create an example program that we can test! We'll start with a function that adds two numbers. Create a file `add.js` with the following contents: + +```js +function add(a, b) { + return a + b; +} + +module.exports = add; +``` + +Now, let's start writing tests! Create a file in a test directory, for example `test/add.js`, and write the following: + +```js +const add = require('../add.js'); + +QUnit.module('add'); + +QUnit.test('two numbers', assert => { + assert.equal(add(1, 2), 3); +}); +``` + +This defines a test suite for the "add" feature, with a single test case that verifies the result of adding two numbers together. Refer to the [`QUnit.test()` page](./api/QUnit/test.md) in our API Documentation for how to organise tests and make other assertions. + +You can now run your first test through the [QUnit CLI](./cli.md). It is recommended that you run the `qunit` command via an npm script, which will automatically find the `qunit` program in your local `node_modules` folder, which is where npm keeps the dependencies you download. In your `package.json` file, specify it like so: + +```json +{ + "scripts": { + "test": "qunit" + } +} +``` + +Then run: + +```bash +npm test +``` + +... and QUnit will run your test! + +```bash +TAP version 13 +ok 1 add > two numbers +1..1 +# pass 1 +# skip 0 +# todo 0 +# fail 0 +``` + +Congrats! You just wrote and executed your first QUnit test! + +Check out the [API documentation](https://api.qunitjs.com) to learn about QUnit APIs for organising tests and making assertions. + +See [Command-line interface](./cli.md) for help with the `qunit` command. + +### Support policy + +QUnit follows the Node.js Long-term Support (LTS) schedule and provides support for Current, Active LTS, and Maintenance LTS releases. + +### Package name prior to 2.4.1 + +Prior to QUnit 2.4.1, the npm package was published under the name "qunit**js**" instead of "qunit". To install earlier versions of QUnit for Node, check out [qunitjs](https://www.npmjs.com/package/qunitjs). + +The 0.x and 1.x versions of the "qunit" package on npm holds an alternative CLI that is now published as [node-qunit](https://github.com/qunitjs/node-qunit). + +### Linting + +The [eslint-plugin-qunit](https://github.com/platinumazure/eslint-plugin-qunit) package has a variety of rules available for enforcing best testing practices as well as detecting broken tests. + +--- + +## In the Browser + +To get started with QUnit in the browser, create a simple HTML file called `test.html` and include the following markup: + +```html + + +Plugins can extend, enhance, and modify QUnit itself; as well as the developer experience of using QUnit.
+ +{{ plugin.description }}
+These organizations and open-source projects use QUnit to keep their code in check.
+ +## Organizations + +This guide will assist you in upgrading from QUnit 1 to QUnit 2.
+ +## Overview + +The QUnit 2 release only removes old methods. The "QUnit 2" methods were introduced as part of QUnit 1.x releases. If you are on QUnit 1.23, you can already migrate gradually, before making the jump. + +The old methods are removed in QUnit 2.0 and replaced with placeholder methods that throw descriptive errors to simplify migration (`"Global 'test()' method is removed, use 'QUnit.test() instead"`). QUnit 2.1 removes that layer and would instead throw native errors like `"ReferenceError: test is not defined"`. + +| QUnit 1.x | QUnit 2.x +|--|-- +| `module()` | [`QUnit.module()`](./api/QUnit/module.md) +| `test()` | [`QUnit.test()`](./api/QUnit/test.md) +| `asyncTest()` | [`QUnit.test()`](./api/QUnit/test.md) with [`assert.async()`](./api/assert/async.md) +| `stop()`/`start()` | [`assert.async()`](./api/assert/async.md) +| `expect()` | [`assert.expect()`](./api/assert/expect.md) +| `ok()`, `equal()`, `deepEqual()`, … | [`assert`](./api/assert/index.md) +| `setup`/`teardown` options | [`beforeEach` and `afterEach` hooks](./api/QUnit/module.md#options-object) + +For plugins and other integrations: + +| QUnit 1.x | QUnit 2.x +|--|-- +| `QUnit.log = …`The [qunit-migrate](https://github.com/apsdehal/qunit-migrate) tool can automate the transition to QUnit 2.
+ +* [Removed global functions](#removed-global-functions) +* [Introducing `assert.async`](#introducing-assertasync) +* [Renamed module hooks](#renamed-module-hooks) +* [Removed legacy callback properties](#removed-legacy-callback-properties) +* [Replace `QUnit.push` with `assert.pushResult`](#replace-qunitpush-with-assertpushresult) +* [Removed `QUnit.init` without replacement](#removed-qunitinit-without-replacement) +* [Removed `QUnit.reset`](#removed-qunitreset) +* [Renamed `QUnit.jsDump` to `QUnit.dump`](#renamed-qunitjsdump-to-qunitdump) +* [Replace `expected` number argument of `QUnit.test`](#replace-expected-number-argument-of-qunittest) +* [Replace `assert.throws(Function, string, message)` signature](#replace-assertthrowsfunction-string-message-signature) + +### Removed global functions + +QUnit 2 no longer uses global functions. The main methods are now part of the `QUnit` interface, and the assertion methods are exposed through a new [`assert`](./api/assert/index.md) object that is bound to each test. + +Before: + +```js +module('example'); + +test('add', function () { + equal(add(2, 3), 5); +}); +``` + +After: + +```js +QUnit.module('example'); + +QUnit.test('add', assert => { + assert.equal(add(2, 3), 5); +}); +``` + +### Introducing `assert.async()` + +Use [`assert.async()`](./api/assert/async.md) instead of the `stop()` and `start()` functions. Calling `assert.async()` returns a `done` function that should be called once the asynchronous operation is finished. + +Similarly, if you were using `asyncTest()`, use the regular [`QUnit.test()`](./api/QUnit/test.md) with [`assert.async()`](./api/async.md) instead. + +Before: + +```js +QUnit.test('navigates to new page', function () { + stop(); + router.navigate(function (newPage) { + equal(newPage.id, 1); + start(); + }); +}); + +// Or + +asyncTest('navigates to new page', function () { + router.navigate(function (newPage) { + equal(newPage.id, 1); + start(); + }); +}); +``` + +After: + +```js +QUnit.test('navigates to new page', assert => { + const done = assert.async(); + router.navigate(newPage => { + assert.equal(newPage.id, 1); + done(); + }); +}); +``` + +### Renamed module hooks + +The [module hooks](./api/QUnit/module.md) `setup` and `teardown` have been renamed to `beforeEach` and `afterEach`. The new names were first introduced in QUnit 1.16, and removed in QUnit 2.0. + +Before: + +```js +QUnit.module('router', { + setup: function () { + this.router = new Router(); + }, + teardown: function () { + this.router.destroy(); + } +}); +``` + +After: + +```js +QUnit.module('router', { + beforeEach: () => { + this.router = new Router(); + }, + afterEach: () => { + this.router.destroy(); + } +}); +``` + +You can also use a [nested scope](./api/QUnit/module.md#nested-scope) as of QUnit 1.20, which makes for simpler sharing of variables and associating of tests with modules. + +Example: + +```js +QUnit.module('router', hooks => { + let router; + + hooks.beforeEach(() => { + router = new Router(); + }); + hooks.afterEach(() => { + router.destroy(); + }); + + QUnit.test('add', assert => { + assert.true(router.add('/about')); + }); +}); +``` + +### Removed legacy callback properties + +Early alpha releases of QUnit 0.x required property assignments to register callback events. In QUnit 1.0, these were deprecated in favour of more modern event registration methods. The ability to use assignments as way to register callbacks was removed in QUnit 2.0. + ++ +See also [`QUnit.on()`](./api/callbacks/QUnit.on.md), which implements the [js-reporters spec](https://github.com/js-reporters/js-reporters) since QUnit 2.2. + +
+ +Before: + +```js +QUnit.log = function (results) { + console.log(results); +}; +``` + +After: + +```js +QUnit.log(function (results) { + console.log(results); +}); +``` + +This applies to all reporting callbacks, specifically: [`begin`](./api/callbacks/QUnit.begin.md), [`done`](./api/callbacks/QUnit.done.md), [`log`](./api/callbacks/QUnit.log.md), [`moduleDone`](./api/callbacks/QUnit.moduleDone.md), [`moduleStart`](./api/callbacks/QUnit.moduleStart.md), [`testDone`](./api/callbacks/QUnit.testDone.md), and [`testStart`](./api/callbacks/QUnit.testStart.md). + +### Replace `QUnit.push()` with `assert.pushResult()` + +To implement custom assertions, assign functions to [`QUnit.assert`](./api/extension/QUnit.assert.md), and inside use [`this.pushResult()`](./api/assert/pushResult.md) instead of `QUnit.push`. This allows assertions to be directly associated with its test context, preventing asynchronous tests from leaking into other tests. + +Before: + +```js +QUnit.assert.mod2 = function (value, expected, message) { + const actual = value % 2; + QUnit.push(actual === expected, actual, expected, message); +}; +``` + +After: + +```js +QUnit.assert.mod2 = function (value, expected, message) { + const actual = value % 2; + this.pushResult({ result: actual === expected, actual, expected, message }); +}; +``` + +### Removed `QUnit.init` without replacement + +This method used to reinitialize the test runner. It should never have been exposed as a public method and is now gone, without replacement. If you've built an integration or runner framework that requires the use of `QUnit.init`, reach out in our [Chat room](https://gitter.im/qunitjs/qunit), or contact us in the [issue tracker](https://github.com/qunitjs/qunit/issues) to help find a replacement. + +### Removed `QUnit.reset` + +This method accessed QUnit's internal fixture reset. This is now gone, without replacement. If your code is using it, you may need to split affected tests into separate tests. + +Before: + +```js +QUnit.test('currentPage', assert => { + router.refresh(); + assert.equal(router.currentPage.id, 1); + + QUnit.reset(); + + history.replaceState('/about'); + router.refresh(); + assert.equal(router.currentPage.id, 42); +}); +``` + +After: + +```js +QUnit.test('currentPage default', assert => { + router.refresh(); + assert.equal(router.currentPage.id, 1); +}); + +QUnit.test('currentPage after replaceState', assert => { + history.replaceState('/about'); + router.refresh(); + assert.equal(router.currentPage.id, 42); +}); +``` + +### Renamed `QUnit.jsDump` to `QUnit.dump` + +Originally `jsDump` was a standalone library imported into QUnit. It has since evolved further within the library. To reflect that, the property was renamed to [`QUnit.dump.parse`](./api/extension/QUnit.dump.parse.md). This should only affect custom reporter code, not regular testsuites. + +Before: + +```js +QUnit.log(obj => { + const actual = QUnit.jsDump.parse(obj.actual); + const expected = QUnit.jsDump.parse(obj.expected); + sendMessage(obj.result, actual, expected); +}); +``` + +After: + +```js +QUnit.log(obj => { + const actual = QUnit.dump.parse(obj.actual); + const expected = QUnit.dump.parse(obj.expected); + sendMessage(obj.result, actual, expected); +}); +``` + +### Replace `expected` number argument of `QUnit.test` + +The optional `expected` argument to `QUnit.test` for specifying the expected number of assertions, was removed. Call `assert.expect()` instead. + +Before: + +```js +QUnit.test('addition', 1, assert => { + assert.equal(add(2, 3), 5); +}); +``` + +After: + +```js +QUnit.test('addition', assert => { + assert.expect(1); + assert.equal(add(2, 3), 5); +}); +``` + +### Replace `assert.throws(Function, string, message)` signature + +The signature of [`assert.throws()`](./api/assert/throws.md) that accepted an error string as second parameter has been removed. This avoids ambiguity with the assertion message, as both parameters were optional. + +It is recommended to use a regular expression or error object as the expected value instead. + +For example, to test the following code: + +```js +function add(a, b) { + if (a === undefined) { + throw new Error('This is an error'); + } +} +``` + +Before: + +```js +QUnit.test('add', assert => { + assert.throws(() => { + add(); + }, 'This is an error', 'Fail if A is undefined'); +}); +``` + +After: + +```js +QUnit.test('add', assert => { + assert.throws(() => { + add(); + }, /This is an error/, 'Fail if A is undefined'); +}); + +// Or + +QUnit.test('add', assert => { + assert.throws(() => { + add(); + }, new Error('This is an error'), 'Fail if A is undefined'); +}); +``` + +See [`assert.throws()`](./api/assert/throws.md) for an overview of the supported signatures. + +Note that in the two-argument signature `assert.throws(Function, string)` has always been interpreted as asserting _anything_ is thrown, with the string argument being the assertion message. This continues to be supported. diff --git a/docsearch.config.json b/docsearch.config.json new file mode 100644 index 000000000..886d73393 --- /dev/null +++ b/docsearch.config.json @@ -0,0 +1,27 @@ +{ + "index_name": "qunitjs_com", + "start_urls": [ + "https://qunitjs.com" + ], + "stop_content": [ + "