diff --git a/.github/workflows/spider-check.yaml b/.github/workflows/spider-check.yaml index d56f2f6fc..a1cfe4bef 100644 --- a/.github/workflows/spider-check.yaml +++ b/.github/workflows/spider-check.yaml @@ -24,10 +24,9 @@ jobs: # - https://example.org # - https://example.github.io/ # - https://example.github.io/my-project/ - MY_SITE: https://api.qunitjs.com + MY_SITE: https://qunitjs.com steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - name: Run hydra-link-checker run: | diff --git a/.github/workflows/typesense.yaml b/.github/workflows/typesense.yaml new file mode 100644 index 000000000..60c8c90b8 --- /dev/null +++ b/.github/workflows/typesense.yaml @@ -0,0 +1,30 @@ +name: typesense +on: + # Once a day at 11:30 UTC + schedule: + - cron: '30 11 * * *' + # Or after a deployment + push: + branches: + - main + # Or manually + workflow_dispatch: + +jobs: + typesense: + name: Update Typesense + if: ${{ github.repository_owner == 'qunitjs' }} # skip on forks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Docsearch Scraper + shell: bash + run: | + # 0.6.0.rc1: https://github.com/typesense/typesense-docsearch-scraper/issues/36 + docker run \ + -e TYPESENSE_API_KEY=${{ secrets.TYPESENSE_ADMIN_KEY }} \ + -e TYPESENSE_HOST="${{ secrets.TYPESENSE_HOST }}" \ + -e TYPESENSE_PORT="443" \ + -e TYPESENSE_PROTOCOL="https" \ + -e CONFIG="$(cat docsearch.config.json | jq -r tostring)" \ + typesense/docsearch-scraper:0.6.0.rc2 diff --git a/RELEASE.md b/RELEASE.md index 46d7cbc43..8a01b4300 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -105,19 +105,19 @@ git show After the release is published, we need to update the website. -Check out the main branch of the [qunitjs/qunitjs.com](https://github.com/qunitjs/qunitjs.com) repository, and ensure it is clean and up-to-date. Run the following script, which will update release links and demos to use the new version: +Check out the main branch of the [qunitjs/qunit](https://github.com/qunitjs/qunit) repository, and ensure it is clean and up-to-date. Run the following script, which will update release links and demos to use the new version: ``` -qunitjs.com$ node build/set-version.js +qunit$ node build/site-set-version.js ``` Stage the changes it made, and commit with the following message: ``` -All: Update url and version to +Docs: Update url and version to ``` -Push the commit, and check the website in a few minutes to verify the change ([deployment log](https://github.com/qunitjs/qunitjs.com/deployments/activity_log?environment=github-pages)). +Push the commit to a branch on origin, wait CI checks to complete, then re-push to the main branch. Check the website in a few minutes to verify the change ([deployment log](https://github.com/qunitjs/qunit/deployments/activity_log?environment=github-pages)). ## Final steps diff --git a/build/npm-search.js b/build/npm-search.js new file mode 100644 index 000000000..922e54143 --- /dev/null +++ b/build/npm-search.js @@ -0,0 +1,70 @@ +/** + * npm-search.js is based on npm-keyword v6.1.0 by @sindresorhus, + * but simplified to not have 32 needless dependencies. + * + * - + * - + */ +'use strict'; +const https = require('https'); +const registryUrl = 'https://registry.npmjs.org/'; + +function fetch(url) { + return new Promise((resolve, reject) => { + const req = https.get(url, (resp) => { + let data = ''; + resp.on('data', (chunk) => { + data += chunk; + }); + resp.on('end', () => { + resolve(data); + }); + }); + req.on('error', reject); + }); +} + +async function search(phrase, options) { + if (options.size < 1 || options.size > 250) { + // This limitation is enforced by the npm registry API. + // + throw new TypeError('Size must be between 1 and 250'); + } + + phrase = encodeURIComponent(phrase).replace('%2C', '+'); + const url = `${registryUrl}-/v1/search?text=${phrase}&size=${options.size}`; + return JSON.parse(await fetch(url)); +} + +/** + * @param {string} keyword + * @return {Object[]} List of package objects + */ +async function keyword(keyword) { + const { objects } = await search('keywords:' + keyword, { size: 250 }); + return objects.map(element => element.package); +} + +module.exports = { search, keyword }; + +// Copyright 2020 Timo Tijhof +// Copyright 2017 Sindre Sorhus (sindresorhus.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/build/site-set-version.js b/build/site-set-version.js new file mode 100644 index 000000000..bd3570c91 --- /dev/null +++ b/build/site-set-version.js @@ -0,0 +1,39 @@ +const fs = require( "fs" ); + +const cdnLinks = [ + + // Match qunit-VERSION.js, qunit-VERSION.css, qunit-VERSION.{css.js} + "qunit-VERSION" +]; +const files = { + "docs/index.md": [ + "vVERSION", + "blob\/VERSION\/History.md", + ...cdnLinks + ], + "docs/intro.md": [ ...cdnLinks ], + "docs/resources/example-add.html": [ ...cdnLinks ], + "docs/resources/example-index.html": [ ...cdnLinks ] +}; + +const version = process.argv[ 2 ]; +if ( typeof version !== "string" || !/^\d+\.\d+\.\d+$/.test( version ) ) { + throw new Error( "Invalid or missing version argument" ); +} + +for ( const [ file, patterns ] of Object.entries( files ) ) { + console.log( `... updating ${file}` ); + for ( let pattern of patterns ) { + const replacement = pattern.replace( "VERSION", version ); + pattern = pattern.replace( "VERSION", "\\d+\\.\\d+\\.\\d+" ); + const find = new RegExp( `\\b${pattern}\\b`, 'g' ); + const content = fs.readFileSync( file, "utf8" ).toString(); + fs.writeFileSync( + file, + content.replace( find, replacement ), + "utf8" + ); + } +} + +console.log( "Done!" ); diff --git a/build/site-update-plugins.js b/build/site-update-plugins.js new file mode 100644 index 000000000..38619e6f7 --- /dev/null +++ b/build/site-update-plugins.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const { keyword } = require('./npm-search.js'); + +(async function main() { + let plugins = await keyword('qunit-plugin'); + plugins = plugins.map((plugin) => ({ + name: plugin.name, + description: plugin.description, + date: plugin.date + })).sort((a, b) => a.name < b.name ? -1 : 1); + fs.writeFileSync('./docs/_data/plugins.json', JSON.stringify(plugins, null, 2) + '\n'); + console.log('Done!'); +}()); diff --git a/docs/README.md b/docs/README.md index 1a5e844b0..787c82f04 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,8 @@ [![Build Status: spider-check](https://github.com/qunitjs/qunit/actions/workflows/spider-check.yaml/badge.svg)](https://github.com/qunitjs/qunit/actions/workflows/spider-check.yaml) -# [api.qunitjs.com](https://api.qunitjs.com/) +# [qunitjs.com](https://qunitjs.com/) + +This directory houses the content and code for the [qunitjs.com](https://qunitjs.com/) website. ## Table of contents @@ -14,8 +16,6 @@ ## Contribute -The API documentation site is hosted at using GitHub Pages. - ### Requirements * [Ruby](https://www.ruby-lang.org/) (tested with Ruby 2.7) @@ -24,11 +24,23 @@ The API documentation site is hosted at using GitHub P To install or update Jekyll and plugins: ```shell -bundle update +qunit/docs/$ bundle update +``` + +To regenerate the site and serve locally at : + +```shell +qunit/docs/$ bundle exec jekyll serve +``` + +### Update plugins + +```shell +qunit/$ node build/site-update-plugins.js ``` -To regenerate the site and serve locally at : +### Update QUnit version ```shell -bundle exec jekyll serve +qunit/$ node build/site-set-version.js VERSION ``` diff --git a/docs/_config.yml b/docs/_config.yml index 04547b3b5..6cab4cca2 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -3,9 +3,9 @@ # Docs: https://jekyllrb.com/docs/configuration/ title: QUnit description: The powerful, easy-to-use JavaScript testing framework. -url: "https://api.qunitjs.com" -baseurl: "" -permalink: /:title/ +url: "https://qunitjs.com" +# For pages (not blog posts) this is equivalant to /:title/ +permalink: /:year/:month/:day/:title/ lang: en timezone: UTC highlighter: rouge @@ -36,7 +36,7 @@ amethyst: # We keep a classic ICO file as well, for compat with de-facto standard # machine discovery, e.g. search engines and analytics software. favicon: /favicon.svg - home_href: https://qunitjs.com + home_href: header_logo: src: /img/logo-with-colored-text.svg width: 250 @@ -47,8 +47,18 @@ amethyst: twitter: qunitjs github: qunitjs gitter: qunitjs/qunit + # https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-typesense typesense: origin: https://typesense.jquery.com collection: qunitjs_com search_only_api_key: Zh8mMgohXECel9wjPwqT7lekLSG3OCgz +# Blog archives +# +# Docs: https://github.com/jekyll/jekyll-archives/ +jekyll-archives: + enabled: + - year + layout: posts-year + permalinks: + year: "/:year/" diff --git a/docs/_data/plugins.json b/docs/_data/plugins.json new file mode 100644 index 000000000..938db51f1 --- /dev/null +++ b/docs/_data/plugins.json @@ -0,0 +1,142 @@ +[ + { + "name": "@matthewp/node-qunit-puppeteer", + "description": "A simple node module for running qunit tests with headless Chromium", + "date": "2021-11-01T12:52:46.858Z" + }, + { + "name": "node-qunit-puppeteer", + "description": "A simple node module for running qunit tests with headless Chromium", + "date": "2022-12-31T10:59:09.869Z" + }, + { + "name": "qunit-assert-canvas", + "description": "A QUnit plugin for asserting individual pixel values within a Canvas element.", + "date": "2016-10-02T02:25:02.752Z" + }, + { + "name": "qunit-assert-classes", + "description": "A set of assertions for checking thats an element has ( or does not have ) any number of classes. The check is order independent and gives a diff of the expected classes.", + "date": "2015-04-29T19:09:20.175Z" + }, + { + "name": "qunit-assert-close", + "description": "A QUnit plugin for asserting that a number is approximately equal (or not) to an expected number, within a given tolerance.", + "date": "2016-10-02T02:25:51.041Z" + }, + { + "name": "qunit-assert-compare", + "description": "A QUnit plugin for asserting numerical comparisons like greater than, less than, etc.", + "date": "2016-10-02T03:13:17.701Z" + }, + { + "name": "qunit-assert-html", + "description": "QUnit HTML assertion addon", + "date": "2016-10-03T02:49:50.045Z" + }, + { + "name": "qunit-assert-nodes", + "description": "A QUnit plugin providing a convenient API for batch acceptance assertions", + "date": "2013-06-25T07:56:50.394Z" + }, + { + "name": "qunit-assert-step", + "description": "A QUnit plugin for asserting the proper sequence in which the code should execute.", + "date": "2016-10-03T03:46:41.981Z" + }, + { + "name": "qunit-assertions-extra", + "description": "Collection of helpful assertions for use with qunit", + "date": "2023-07-03T22:41:29.910Z" + }, + { + "name": "qunit-ava-spec", + "description": "Helper functions for using QUnit as if it was ava/ava-spec.", + "date": "2022-11-10T20:10:03.296Z" + }, + { + "name": "qunit-composite", + "description": "Run multiple QUnit test suite pages.", + "date": "2016-10-02T01:26:01.185Z" + }, + { + "name": "qunit-dark", + "description": "A kind of dark theme for qunit", + "date": "2014-03-20T17:47:37.864Z" + }, + { + "name": "qunit-dom", + "description": "High Level DOM Assertions for QUnit", + "date": "2023-10-12T14:40:16.837Z" + }, + { + "name": "qunit-junit", + "description": "Produce JUnit-style XML test reports with QUnit.", + "date": "2023-07-08T17:02:23.203Z" + }, + { + "name": "qunit-pending", + "description": "A QUnit plugin to add the \"pending\" test syntax to QUnit, a la Mocha.", + "date": "2016-10-02T01:55:55.632Z" + }, + { + "name": "qunit-puppeteer-reporter", + "description": "headless browser testing for QUnit test suites", + "date": "2020-08-01T08:31:56.699Z" + }, + { + "name": "qunit-puppeteer-runner", + "description": "Runs QUnit tests in a Puppeteer instance and compiles results to JUnit XML", + "date": "2023-07-20T21:46:06.528Z" + }, + { + "name": "qunit-reporter-junit", + "description": "Produce JUnit-style XML test reports with QUnit.", + "date": "2016-10-16T01:23:43.596Z" + }, + { + "name": "qunit-reporter-lcov", + "description": "Produce lcov test reports with QUnit", + "date": "2015-03-15T20:31:35.403Z" + }, + { + "name": "qunit-retry", + "description": "Drop in replacement for qunit `test` which retries a failed test.", + "date": "2021-04-05T08:44:23.358Z" + }, + { + "name": "qunit-theme-burce", + "description": "A QUnit theme by Bryce Dorn.", + "date": "2014-06-09T22:03:07.465Z" + }, + { + "name": "qunit-theme-ember", + "description": "A theme for the QUnit web UI test runner powered by the Ember styleguide.", + "date": "2023-12-09T14:25:04.302Z" + }, + { + "name": "qunit-theme-gabe", + "description": "A QUnit theme by Gabe Hendry.", + "date": "2020-09-14T23:15:22.306Z" + }, + { + "name": "qunit-theme-ninja", + "description": "A QUnit theme for ninjas.", + "date": "2022-04-18T23:56:40.520Z" + }, + { + "name": "qunit-theme-nv", + "description": "A QUnit theme.", + "date": "2019-01-03T23:49:09.721Z" + }, + { + "name": "qunit-wait-for", + "description": "Wait for a QUnit assertion", + "date": "2021-11-29T21:09:31.345Z" + }, + { + "name": "qunitx-dom", + "description": "High Level DOM Assertions for QUnit", + "date": "2021-05-31T16:37:57.111Z" + } +] diff --git a/docs/_data/projects.yml b/docs/_data/projects.yml new file mode 100644 index 000000000..dba1115f5 --- /dev/null +++ b/docs/_data/projects.yml @@ -0,0 +1,242 @@ +# General: +# - Up to three projects per entry. +# +# Organizations should meet these criteria: +# +# - One or more its projects are under an OSI-approved free software license and use QUnit. +# - Meets at least one of the following notability criteria: +# - has an official social media account with 5000+ followers. +# - or, an English Wikipedia article exists about the organization, and has existed for at least one year. +# +# Projects should meet these criteria: +# +# - Published under an OSI-approved free software license. +# - Has had its 1.0 release at least one year ago. +# - Meets at least one of the following notability criteria: +# - published to a package manager with 50+ non-dev dependent packages. +# - or, maintained on a social coding platform (e.g. GitLab, GitHub) with 500+ stars. +# - or, has a official social media account with 1000+ followers. +# - or, an English Wikipedia article exists about the project, and has existed for at least one year. +# +orgs: + + - name: Addepar + href: https://github.com/Addepar + sub: + - name: ember-table + href: https://github.com/Addepar/ember-table + + - name: Discourse + href: https://github.com/discourse + sub: + - name: Discourse + href: https://github.com/discourse/discourse + - name: discourse-subscriptions + href: https://github.com/discourse/discourse-subscriptions + + - name: DocumentCloud + href: https://www.documentcloud.org/opensource + sub: + - name: Underscore.js + href: https://github.com/jashkenas/underscore + - name: Backbone.js + href: https://github.com/jashkenas/backbone + + - name: Filament Group + href: https://github.com/filamentgroup + sub: + - name: formcore + href: https://github.com/filamentgroup/formcore/ + - name: layersnap + href: https://github.com/filamentgroup/layersnap + - name: tablesaw + href: https://github.com/filamentgroup/tablesaw + + - name: HashiCorp + href: https://github.com/hashicorp + sub: + - name: Vault + href: https://github.com/hashicorp/vault + - name: Consul + href: https://github.com/hashicorp/consul + - name: Nomad + href: https://github.com/hashicorp/nomad + + - name: Khan Academy + href: https://github.com/Khan + sub: + - name: KAS + href: https://github.com/Khan/KAS + - name: structured.js + href: https://github.com/Khan/structuredjs + + - name: Kiwix + href: https://github.com/kiwix + sub: + - name: kiwix-js + href: https://github.com/kiwix/kiwix-js + + - name: Twitter + href: https://github.com/twitter + sub: + - name: Hogan.js + href: https://github.com/twitter/hogan.js + - name: twitter-text + href: https://github.com/twitter/twitter-text + + - name: Wikimedia + href: https://doc.wikimedia.org/ + sub: + - name: MediaWiki + href: https://github.com/wikimedia/mediawiki + - name: VisualEditor + href: https://github.com/wikimedia/VisualEditor + - name: CSSJanus + href: https://github.com/cssjanus/cssjanus + + - name: WordPress + href: https://github.com/WordPress + sub: + - name: WordPress + href: https://github.com/WordPress/wordpress-develop + +projects: + - name: Bestie + href: https://github.com/bestiejs/benchmark.js + sub: + - name: Benchmark.js + href: https://github.com/bestiejs/benchmark.js + - name: Platform.js + href: https://github.com/bestiejs/platform.js + + - name: Bootstrap + href: https://github.com/twbs + sub: + - name: Bootstrap + href: https://github.com/twbs/bootstrap + - name: bootlint + href: https://github.com/twbs/bootlint + + - name: CefSharp + href: https://github.com/cefsharp + sub: + - name: CefSharp + href: https://github.com/cefsharp/CefSharp + + - name: core-js + href: https://github.com/zloirock/core-js + sub: + - name: core-js + href: https://github.com/zloirock/core-js + + - name: jQuery + href: https://github.com/jquery + sub: + - name: jQuery + href: https://github.com/jquery/jquery + - name: Sizzle + href: https://github.com/jquery/sizzle + - name: jQuery UI + href: https://github.com/jquery/jquery-ui + + - name: jQuery community + href: https://www.npmjs.com/search?q=keywords%3Ajquery-plugin + sub: + - name: jquery-validation + href: https://github.com/jquery-validation/jquery-validation + - name: mockjax + href: https://github.com/jakerella/jquery-mockjax + - name: inputmask + href: https://www.npmjs.com/package/inputmask + + - name: js-cookie + href: https://github.com/js-cookie/js-cookie + sub: + - name: js-cookie + href: https://github.com/js-cookie/js-cookie + + - name: Ember.js + href: https://github.com/emberjs + sub: + - name: Ember.js + href: https://github.com/emberjs/ember.js + - name: ember-qunit + href: https://github.com/emberjs/ember-qunit + - name: ember-twiddle + href: https://github.com/ember-cli/ember-twiddle + + - name: Ember.js community + href: https://www.npmjs.com/search?q=keywords%3Aember-addon + sub: + - name: ember-moment + href: https://github.com/stefanpenner/ember-moment + - name: ember-intl + href: https://github.com/ember-intl/ember-intl + - name: ember-table + href: https://github.com/Addepar/ember-table + + - name: Fabric.js + href: https://github.com/fabricjs + sub: + - name: Fabric.js + href: https://github.com/fabricjs/fabric.js + + - name: Globalize + href: https://github.com/globalizejs/globalize + sub: + - name: Globalize + href: https://github.com/globalizejs/globalize + + - name: Moment.js + href: https://github.com/moment + sub: + - name: Moment.js + href: https://github.com/moment/moment + + - name: Paper.js + href: https://github.com/paperjs + sub: + - name: Paper.js + href: https://github.com/paperjs/paper.js + + - name: StealJS + href: https://github.com/stealjs/ + sub: + - name: StealJS + href: https://github.com/stealjs/steal + - name: steal-qunit + href: https://github.com/stealjs/steal-qunit + - name: steal-tools + href: https://github.com/stealjs/steal-tools + + - name: three.js + href: https://github.com/mrdoob/three.js + sub: + - name: three.js + href: https://github.com/mrdoob/three.js + + - name: Video.js + href: https://github.com/videojs/video.js + sub: + - name: video.js + href: https://github.com/videojs/video.js + - name: videojs/http-streaming + href: https://github.com/videojs/http-streaming + - name: mux.js + href: https://github.com/videojs/mux.js + + - name: Wikibase + href: https://wikiba.se/ + sub: + - name: Wikibase + href: https://github.com/wikimedia/Wikibase + - name: data-model + href: https://github.com/wmde/WikibaseDataModelJavaScript + - name: data-values + href: https://github.com/wmde/DataValuesJavaScript + + - name: ZeroClipboard + href: https://github.com/zeroclipboard + sub: + - name: ZeroClipboard + href: https://github.com/zeroclipboard/zeroclipboard diff --git a/docs/_data/sitenav.yml b/docs/_data/sitenav.yml index 3a86fe15a..7a685f05d 100644 --- a/docs/_data/sitenav.yml +++ b/docs/_data/sitenav.yml @@ -1,20 +1,24 @@ - name: Guides - href: https://qunitjs.com/guides/ + href: /guides/ sub: - name: Getting Started - href: https://qunitjs.com/intro/ + href: /intro/ - name: Command-line interface - href: https://qunitjs.com/cli/ + href: /cli/ - name: Plugins - href: https://qunitjs.com/plugins/ + href: /plugins/ - name: 2.x Upgrade Guide - href: https://qunitjs.com/upgrade-guide-2.x/ + href: /upgrade-guide-2.x/ - name: Documentation - href: / + href: /api/ - name: About - href: https://qunitjs.com/about/ + href: /about/ sub: - name: Who's using QUnit? - href: https://qunitjs.com/projects/ + href: /projects/ + - name: Browser support + href: /intro/#browser-support - name: About QUnit - href: https://qunitjs.com/about/ + href: /about/ + - name: Brand guidelines + href: /brand/ diff --git a/docs/_sass/amethyst-variables.scss b/docs/_sass/amethyst-variables.scss index ce2d368cf..1f22b990a 100644 --- a/docs/_sass/amethyst-variables.scss +++ b/docs/_sass/amethyst-variables.scss @@ -1,5 +1,5 @@ // Amethyst theme variables for QUnit -// https://brand.jquery.org/colors/#qunit-purple +// https://qunitjs.com/brand/ // Primary color // diff --git a/docs/_sass/custom.scss b/docs/_sass/custom.scss index 8c1d7db08..82e755eb4 100644 --- a/docs/_sass/custom.scss +++ b/docs/_sass/custom.scss @@ -1 +1,37 @@ -// Custom styles for api.qunitjs.com +// Custom styles for qunitjs.com + +h3 a { + // Improve balance of layout color contrast on "Plugins" and "Projects" pages + // (not everything the same color) + color: inherit; +} + +/* Plugins */ +#plugins { + list-style: none; + padding: 0; +} +.plugin { + border-bottom: 1px solid $color-off-white; +} + +/* Brand */ +.q-color-icon { + display: inline-block; + vertical-align: middle; + width: 1em; + height: 1em; + border-radius: 1em; +} +.q-color-block { + display: block; + padding: 1em; +} + +.main img { + max-width: 100%; + max-height: 100vh; +} +.main figure { + text-align: center; +} diff --git a/docs/about.md b/docs/about.md new file mode 100644 index 000000000..822d523d7 --- /dev/null +++ b/docs/about.md @@ -0,0 +1,60 @@ +--- +layout: page +title: About +--- + +

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 + +

+ +## Logo + +The primary QUnit purple should always be used when presenting the QUnit brand. Please use this color for the logo mark as well as the tagline when presented on a light background. When presented on a dark background, all text, including name and tagline, must be white. + +[Download QUnit artwork presskit](https://github.com/openjs-foundation/artwork/tree/main/projects/qunit#qunit-artwork). + +
+ +
+ +Use of any trademark or logo is subject to the trademark policy available at . A list of the trademarks covered by this policy can be found at . + +## Brand history + +### 2011 + +
QUnit logo 2011
+ +Prior to January 2013, the QUnit brand featured a green color theme. + +* QUnit Light Green `#1d923c` +* QUnit Dark Green `#00733c` + +A temporary logo used the Myriad Semibold font for the project name. + +### 2012 + +
QUnit logo 2012
+
QUnit logo 2012
+ + +In 2012, the logo was updated to align with the other jQuery Foundation projects, based on the jQuery logo as [designed by Scott Jehl](https://blog.jquery.com/2008/08/29/jquerycom-site-redesign/) in 2008. The 2012 version of the QUnit logo was [created](https://github.com/qunitjs/qunit/issues/222) by [Zach McCarthy](https://github.com/zrmccarthy). + +The 2012 website theme was [designed and developed by Doug Neiner](http://web.archive.org/web/20130918130115/http://appendto.com/blog/2013/01/jquery-design-doug-neiner/) and [Darcy Clarke](https://twitter.com/dougneiner/status/44191485884772352), which would be deployed to jquery.com [two months later](https://blog.jquery.com/2013/01/23/a-site-to-behold-open-content-design-comes-to-jquery-2/). You can browse the [2012 version of the website](https://web.archive.org/web/20121210184108/http://qunitjs.com/) at the Internet Archive. + +![](/img/2012-website-qunit.png) + +### 2013 + +* QUnit Primary Purple `#9C3493` +* QUnit Secondary Purple `#390F39` + +In January 2013, QUnit [changed](https://github.com/jquery/jquery-wp-content/commit/3eaa0f780b03c894b8577755be8028526b90c99b) its branding to its now-beloved purple. This was the outcome of a 2012 [color study](https://github.com/qunitjs/qunitjs.com/issues/20) in collaboration with FortySeven Media, that reviewed it in context of other jQuery Foundation projects. + +You can browse the [2013 version of the website](https://web.archive.org/web/20180128085010/http://qunitjs.com/) at the Internet Archive. + +![](/img/2013-website-qunit.png) + +### 2020 + +In 2018, Trent Willis [designed](https://github.com/qunitjs/qunitjs.com/issues/151#issuecomment-655154878) a new homepage for QUnit. In 2020, Timo Tijhof [launched](https://github.com/qunitjs/qunit/issues/1458#issuecomment-661576550) the redesign with a matching redesign of the API documentation. The QUnit site framework is published as [jekyll-theme-amethyst](https://github.com/qunitjs/jekyll-theme-amethyst). + +![](/img/2020-website-qunit.png) diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 000000000..1cd273fc5 --- /dev/null +++ b/docs/cli.md @@ -0,0 +1,114 @@ +--- +layout: page +title: Command-line interface +redirect_from: + - "/node/" +amethyst: + toc: true +--- + +

+ +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, --filter run only matching module or test names + -m, --module run only the specified module + -r, --reporter [name] specify the reporter to use + --require specify a module or script to include before running any tests + --seed [value] specify a seed to re-order your tests + -w, --watch watch files for changes and re-run the test suite + -h, --help display help for command +``` + +### `--filter` + +Only run tests that match the given filter. The filter is matched against the module and test name, and may either be substring match (case insensitive), or a regular expression. + +Examples: `--filter foo`, `--filter !foo`, `--filter "/foo/"`, `--filter "!/foo/"` + +Check [`QUnit.config.filter`](./api/config/filter.md) for more information. + +### `--module` + +Only run tests that belong to the specified module. The name is matched case-insensitively, but must otherwise be complete. + +Examples: `--module foo`, `--module "Foo"` + +Check [`QUnit.config.module`](./api/config/module.md) for more information. + +### `--reporter` + +By default, the TAP reporter is used. + +Run `qunit --reporter ` to use a different reporter, where `` can be the name of a built-in reporter, or an Node module that implements the [js-reporters](https://github.com/js-reporters/js-reporters) spec. The reporter will be loaded and initialised automatically. + +Built-in reporters: + +* `tap`: [TAP compliant](https://testanything.org/) reporter. +* `console`: Log the JSON object for each reporter event from [`QUnit.on`](./api/callbacks/QUnit.on.md). Use this to explore or debug the reporter interface. + +### `--require` + +These modules or scripts will be required before any tests begin running. + +This can be used to install Node.js require hooks, such as for TypeScript ([ts-node/register](https://typestrong.org/ts-node/docs/)), Babel ([@babel/register](https://babeljs.io/docs/en/babel-register/)), or CoffeeScript ([coffeescript/register](https://coffeescript.org/)). + +It can also be used for your own setup scripts to bootstrap the environment, or tweak `QUnit.config`. For example: + +```bash +qunit --require ./test/setup.js +``` + +```js +// test/setup.js +QUnit.config.noglobals = true; +QUnit.config.notrycatch = true; + +global.MyApp = require( './index' ); +``` + +See [QUnit.config](./api/config/index.md) for all available configuration options. + +### `--seed` + +This option assigns [`QUnit.config.seed`](./api/config/seed.md) for you. + +## Node.js CLI options + +The QUnit CLI uses Node.js. You can pass [Node.js CLI](https://nodejs.org/api/cli.html) options via the [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#cli_node_options_options) environment variable. For example, to use `--enable-source-maps` or `--inspect`, invoke QUnit as follows: + +``` +NODE_OPTIONS='--enable-source-maps' qunit test/ +``` + +## Code coverage + +Generate code coverage reports with [nyc](https://istanbul.js.org/): + +```json +{ + "scripts": { + "test": "nyc qunit" + }, + "devDependencies": { + "nyc": "*", + "qunit": "*" + } +} +``` + +See [/test/integration/nyc/](https://github.com/qunitjs/qunit/tree/main/test/integration/nyc) in the QUnit repo for a minimal example. + +For a more elaborate example showcasing a unified test coverage report for tests in both Node.js and a headless browser, see [Krinkle/example-node-and-browser-qunit](https://github.com/Krinkle/example-node-and-browser-qunit-ci/). diff --git a/docs/img/2011-logo-qunit.png b/docs/img/2011-logo-qunit.png new file mode 100644 index 000000000..a37e56219 Binary files /dev/null and b/docs/img/2011-logo-qunit.png differ diff --git a/docs/img/2012-logo-qunit.png b/docs/img/2012-logo-qunit.png new file mode 100644 index 000000000..bcbde1b0b Binary files /dev/null and b/docs/img/2012-logo-qunit.png differ diff --git a/docs/img/2012-logo-qunit@2x.png b/docs/img/2012-logo-qunit@2x.png new file mode 100644 index 000000000..cd1d4a170 Binary files /dev/null and b/docs/img/2012-logo-qunit@2x.png differ diff --git a/docs/img/2012-website-qunit.png b/docs/img/2012-website-qunit.png new file mode 100644 index 000000000..8e855f7ae Binary files /dev/null and b/docs/img/2012-website-qunit.png differ diff --git a/docs/img/2012b-logo-qunit.png b/docs/img/2012b-logo-qunit.png new file mode 100644 index 000000000..d1fb44c38 Binary files /dev/null and b/docs/img/2012b-logo-qunit.png differ diff --git a/docs/img/2013-logo-qunit_color_study.png b/docs/img/2013-logo-qunit_color_study.png new file mode 100644 index 000000000..4a8a431ac Binary files /dev/null and b/docs/img/2013-logo-qunit_color_study.png differ diff --git a/docs/img/2013-website-qunit.png b/docs/img/2013-website-qunit.png new file mode 100644 index 000000000..6e0514374 Binary files /dev/null and b/docs/img/2013-website-qunit.png differ diff --git a/docs/img/2020-website-qunit.png b/docs/img/2020-website-qunit.png new file mode 100644 index 000000000..6db9b37ef Binary files /dev/null and b/docs/img/2020-website-qunit.png differ diff --git a/docs/img/logo-text.svg b/docs/img/logo-text.svg new file mode 100644 index 000000000..47e4183ce --- /dev/null +++ b/docs/img/logo-text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/img/logo.png b/docs/img/logo.png new file mode 100644 index 000000000..9e343f3a5 Binary files /dev/null and b/docs/img/logo.png differ diff --git a/docs/img/logo.svg b/docs/img/logo.svg new file mode 100644 index 000000000..8c15c213c --- /dev/null +++ b/docs/img/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 965d5ca18..2287bac65 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,15 +1,99 @@ --- -layout: page-api -title: QUnit API -excerpt: API reference documentation for QUnit. -amethyst: - prepend_description_heading: false -redirect_from: - - "/category/all/" +layout: home +home_img: /img/logo-text.svg +home_primary_btn: + name: Get Started + href: /intro/ +home_secondary_btn: + name: View the Docs + href: /api/ --- -QUnit is a powerful, easy-to-use JavaScript unit test suite. +
+
+

Easy

+

Easy, zero configuration setup for any Node.js project and minimal configuration for Browser-based projects.

+
-If you're new to QUnit, check out Getting Started. +
+

Universal

+

Tests can be run anywhere; Node, your browser, even inside a Web Worker. Test your code where it runs.

+
-QUnit has no dependencies and supports Node.js, SpiderMonkey, and all major browsers. +
+

Extensible

+

Flexible APIs for custom assertions, runners, and reporters mean you can extend QUnit to fit your needs.

+
+
+ +--- + +## A Quick Example + +```js +function add(a, b) { + return a + b; +} + +QUnit.module('add', hooks => { + QUnit.test('two numbers', assert => { + assert.equal(add(1, 2), 3); + }); +}); +``` + +
+ +
+ +### Browser Result + + + +
+ +
+ +### CLI Result + +```tap +TAP version 13 +ok 1 add > two numbers +1..1 +# pass 1 +# skip 0 +# todo 0 +# fail 0 +``` + +
+ +
+ +--- + +## Current Release + +

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 + + +Test Suite + + +
+
+ + +``` + +That's all the markup you need to start writing tests. Note that this loads the library from the [jQuery CDN](https://code.jquery.com/qunit/). + +See also [Integrations & Downloads](#integrations) for integration you can use to automate browser testing. These usually also manage the HTML file for you. + +Let's add the following script, which tests an example `add()` function for adding two numbers together: + +```html + +``` + +This code defines a test module for the `add()` function and verifies the result of adding two numbers. + +If you open this up in the browser you'll find a detailed report of the tests that ran and their assertions, as well as various options for filtering and re-running individual tests to help during development. Like so: + + + +Congrats! You just wrote and executed your first QUnit test! + +Check out the [API documentation](./api/index.md) to learn more about the QUnit APIs for organising tests and making assertions. + +### Browser support + +QUnit currently supports the following browsers: + +* Internet Explorer: 9+ +* Edge: 15+ (both legacy MSEdge and Chromium-based) +* Firefox: 45+ +* Safari: 9+ +* Opera: 36+ +* Chrome: 58+ +* Android: 4.3+ +* iOS: 7+ (Mobile Safari) + +For older browsers, such as Internet Explorer 6-8, Opera 12+, or Safari 5+, please use the 1.x series of QUnit. + +### Integrations + +The following integrations can be used to automate the running of browser tests with QUnit: + +* [grunt-contrib-qunit](https://github.com/gruntjs/grunt-contrib-qunit) for [Grunt task runner](https://gruntjs.com/) (test Headless Chrome). +* [testem](https://github.com/testem/testem) (test any local browser, including headless) +* [wdio-qunit-service](https://webdriver.io/docs/wdio-qunit-service/) (test any local, headless, or cloud browser; via WDIO selenium driver) +* [Karma](https://karma-runner.github.io/latest/index.html) with [karma-qunit](https://github.com/karma-runner/karma-qunit) (test any local browser or cloud). +* [node-qunit-puppeteer](https://github.com/ameshkov/node-qunit-puppeteer) (test Headless Chrome). +* [StealJS](https://stealjs.com/) with [steal-qunit](https://stealjs.com/docs/steal-qunit.html) via [Testee](https://www.npmjs.com/package/testee) (test any local browser or cloud). +* [testcafe](https://github.com/DevExpress/testcafe) (test any local browser or cloud). + +Example projects: + +* [Krinkle/example-node-and-browser-qunit-ci](https://github.com/Krinkle/example-node-and-browser-qunit-ci/): Run QUnit tests locally and in CI, on Headless Firefox and Chrome (using Karma), and with Node.js.
Also demonstrates code coverage, and testing of isomorphic JavaScript projects. + +### Release channels + +These are the officially supported download channels for QUnit releases: + +* Download: + + QUnit has no runtime dependencies for browser use. You can save the [`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) files directly from the [jQuery CDN](https://code.jquery.com/qunit/), which is powered by [StackPath](https://www.stackpath.com/). + + Or download them via the terminal: + + ```bash + curl -o qunit.css 'https://code.jquery.com/qunit/qunit-2.20.1.css' + curl -o qunit.js 'https://code.jquery.com/qunit/qunit-2.20.1.js' + ``` + +* npm Registry: + + If your development workflow uses [Node.js](https://nodejs.org/en/), you can install the [qunit](https://www.npmjs.com/package/qunit) package 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 `node_modules/qunit/qunit/qunit.css` and `node_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()`](https://nodejs.org/api/modules.html#modules_require_resolve_request_options) to locate `qunit/qunit/qunit.js` and `qunit/qunit/qunit.css`. Alternatively, use one of the [Integrations](#integrations) such as karma-qunit which do all of that for you. + +* Bower: + + Using [Bower](https://bower.io/): + + ```bash + bower install --save-dev qunit + ``` + + Then reference `bower_components/qunit/qunit/qunit.css` and `bower_components/qunit/qunit/qunit.js` in your HTML. + +--- + +## Further Reading + +* [Introdution to JavaScript Unit Testing](https://coding.smashingmagazine.com/2012/06/introduction-to-javascript-unit-testing/), Jörn Zaefferer (2012). diff --git a/docs/plugins.md b/docs/plugins.md new file mode 100644 index 000000000..050879d6f --- /dev/null +++ b/docs/plugins.md @@ -0,0 +1,22 @@ +--- +layout: page +title: Plugins +redirect_from: + - "/addons/" +--- + +

Plugins can extend, enhance, and modify QUnit itself; as well as the developer experience of using QUnit.

+ +
    + {% assign _plugins = site.data.plugins | sort: "date" | reverse -%} + {%- for plugin in _plugins -%} +
  • +

    {{ plugin.name }}

    +

    {{ plugin.description }}

    +
  • + {% endfor %} +
+ +Plugins are sometimes known as QUnit addons. + +_Note: This list is automatically generated from npm packages using the [**qunit-plugin** keyword](https://www.npmjs.com/search?q=keywords:qunit-plugin)._ diff --git a/docs/projects.md b/docs/projects.md new file mode 100644 index 000000000..4c441d1f2 --- /dev/null +++ b/docs/projects.md @@ -0,0 +1,35 @@ +--- +layout: page +title: Who's using QUnit? +--- + +

These organizations and open-source projects use QUnit to keep their code in check.

+ +## Organizations + +
+{% assign entries = site.data.projects.orgs | sort_natural: "name" -%} +{%- for entry in entries -%} +
+### [{{ entry.name }}]({{ entry.href }}) +{%- for sub in entry.sub %} +[{{ sub.name }}]({{ sub.href }}){% if entry.sub.last != sub %}, {% endif %} +{%- endfor %} +
+{% endfor %} +
+
+ +## Projects + +
+{% assign entries = site.data.projects.projects | sort_natural: "name" -%} +{%- for entry in entries -%} +
+### [{{ entry.name }}]({{ entry.href }}) +{%- for sub in entry.sub %} +[{{ sub.name }}]({{ sub.href }}){% if entry.sub.last != sub %}, {% endif %} +{%- endfor %} +
+{% endfor %} +
diff --git a/docs/resources/example-add.html b/docs/resources/example-add.html new file mode 100644 index 000000000..15b185ae0 --- /dev/null +++ b/docs/resources/example-add.html @@ -0,0 +1,20 @@ + + +Test Suite + + +
+
+ + + + diff --git a/docs/resources/example-index.html b/docs/resources/example-index.html new file mode 100644 index 000000000..00a2b13d9 --- /dev/null +++ b/docs/resources/example-index.html @@ -0,0 +1,20 @@ + + +Test Suite + + +
+
+ + + + diff --git a/docs/upgrade-guide-2.x.md b/docs/upgrade-guide-2.x.md new file mode 100644 index 000000000..c2b019616 --- /dev/null +++ b/docs/upgrade-guide-2.x.md @@ -0,0 +1,346 @@ +--- +layout: page +title: QUnit 2.0 Upgrade Guide +--- + + +

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 = …`
`QUnit.begin = …`
… | [`QUnit.log(…)`](./api/callbacks/QUnit.log.md),
[`QUnit.begin(…)`](./api/callbacks/QUnit.begin.md),
… +| `QUnit.push()` | [`assert.pushResult()`](./api/assert/pushResult.md) +| `QUnit.jsDump.parse()` | [`QUnit.dump.parse()`](./api/extension/QUnit.dump.parse.md) + +## Changes + +

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": [ + "