Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
All: Step 1 of site unification, import api content
Browse files Browse the repository at this point in the history
* Import content from https://github.com/qunitjs/qunit/tree/8a6723f7e2b4fad41779734301d16135c9e397ad/docs
  into api/ directory.

* Modify the imported pages to add a `redirect_from` entry
  reflecting their previous URL on the api.qunitjs.com domain.
  For example,
  api.qunitjs.com/QUnit/test/ is imported here as
  qunitjs.com/api/QUnit/test/ with a redirect from
  qunitjs.com/QUnit/test/

  This way, once we redirect api.qunitjs.com to qunitjs.com,
  the old path will be recognised and redirected accordingly
  from api.qunitjs.com/QUnit/test/ to qunitjs.com/api/QUnit/test/.

* Modify pre-existing pages to refer to the in-repo Markdown files
  instead of raw URLs. This aids local testing, as well as makes sure
  that jekyll builds can automatically validate that all linked pages
  exist, and will output links with the canonical URL.

Ref qunitjs/qunit#1754
  • Loading branch information
Krinkle committed Mar 31, 2024
1 parent 3e9cb45 commit 526fc72
Show file tree
Hide file tree
Showing 89 changed files with 4,262 additions and 41 deletions.
2 changes: 0 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ exclude:
- vendor
- build


# Theme settings
#
# Amethyst theme options are documented at:
Expand Down Expand Up @@ -54,7 +53,6 @@ amethyst:
collection: qunitjs_com
search_only_api_key: Zh8mMgohXECel9wjPwqT7lekLSG3OCgz


# Blog archives
#
# Docs: https://github.com/jekyll/jekyll-archives/
Expand Down
2 changes: 1 addition & 1 deletion _data/projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ projects:
href: https://github.com/videojs/http-streaming
- name: mux.js
href: https://github.com/videojs/mux.js

- name: Wikibase
href: https://wikiba.se/
sub:
Expand Down
23 changes: 23 additions & 0 deletions _data/sidebar_api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- group: main
expand: initial

- group: assert

- group: callbacks

- group: async
# These pages are all in at least one other group.
# It exists for discoverability, but we don't need
# to highlight its pages in two places.
expand: false

- title: Configuration
group: config

- group: extension

- group: deprecated
expand: false

# - group: removed
# expand: false
3 changes: 2 additions & 1 deletion _data/sitenav.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- name: Guides
href: /guides/
sub:
- name: Getting Started
href: /intro/
Expand All @@ -9,7 +10,7 @@
- name: 2.x Upgrade Guide
href: /upgrade-guide-2.x/
- name: Documentation
href: https://api.qunitjs.com/
href: /api/
- name: About
href: /about/
sub:
Expand Down
39 changes: 39 additions & 0 deletions api/QUnit/hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
layout: page-api
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"
---

`QUnit.hooks.beforeEach( callback )`<br>
`QUnit.hooks.afterEach( callback )`

Register a global callback to run before or after each test.

| parameter | description |
|-----------|-------------|
| callback (function) | Callback to execute. Called with an [assert](../assert/index.md) argument. |

This is the equivalent of applying a `QUnit.module()` hook to all modules and all tests, including global tests that are not associated with any module.

Similar to module hooks, global hooks support async functions or returning a Promise, which will be waited for before QUnit continues executing tests. Each global hook also has access to the same `assert` object and test context as the [QUnit.test](./test.md) that the hook is running for.

For more details about hooks, refer to [QUnit.module § Hooks](./module.md#hooks).

## Examples

```js
QUnit.hooks.beforeEach(function () {
this.app = new MyApp();
});

QUnit.hooks.afterEach(async function (assert) {
assert.deepEqual([], await this.app.getErrors(), 'MyApp errors');

MyApp.reset();
});
```
7 changes: 7 additions & 0 deletions api/QUnit/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: group
group: main
title: Main methods
redirect_from:
- "/QUnit/"
---
50 changes: 50 additions & 0 deletions api/QUnit/load.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
layout: page-api
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"
---

`QUnit.load()`

Inform the test runner that your source code and tests have finished loading.

This method was used in conjunction with the [`QUnit.config.autostart`](../config/autostart.md) option in a web browser, to indicate when your custom way of loading scripts is complete.

As of [QUnit 2.1.1](https://github.com/qunitjs/qunit/releases/tag/2.1.1), calls to `QUnit.load()` are no longer needed. Existing calls are usually ignored and safe to remove.

<p class="note note--warning" markdown="1">This method is __deprecated__. Remove call, or replace by a single call to [`QUnit.start()`](./start.md).</p>

## Changelog

| UNRELEASED | Deprecated. Use [`QUnit.start()`](./start.md) instead.
| [QUnit 2.1.1](https://github.com/qunitjs/qunit/releases/tag/2.1.1) | `QUnit.start()` no longer requires calling `QUnit.load()` first.

## Migration guide

If you still call `QUnit.load()` with QUnit 2.2 or later, the call is usually redundant and safe to remove.

### If you call both `QUnit.load()` and `QUnit.start()`

If your project started with QUnit 1.x, and you use `QUnit.config.autostart = false`, then you might be calling both of these methods. In the QUnit 1.x era, [`QUnit.start()`](./start.md) required that you also call `QUnit.load()` first.

This is no longer needed since [QUnit 2.1.1](https://github.com/qunitjs/qunit/releases/tag/2.1.1), and the call to `QUnit.load()` is safe to remove.

### If you call `QUnit.load()`

Prior to QUnit 2.21, the built-in HTML Reporter called `QUnit.load()` from the window.onload event, which in turn gracefully calls `QUnit.start()` if it has not been called already.

If your test runner works in a similar way, call [`QUnit.start()`](./start.md) instead of `QUnit.load()`. This will solve the deprecation warning and prepares you for QUnit 3.

### Karma runner

```
QUnit.load is deprecated and will be removed in QUnit 3.0.
```

If you encounter this warning in Karma output, upgrade to [karma-qunit](https://github.com/karma-runner/karma-qunit) 4.2.0 or later, which [fixes](https://github.com/karma-runner/karma-qunit/pull/184) this warning.
Loading

0 comments on commit 526fc72

Please sign in to comment.