-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First introduced in QUnit 2.16.0 with f8948c9.
- Loading branch information
Showing
16 changed files
with
278 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
layout: page-api | ||
title: QUnit.reporters.console | ||
excerpt: | | ||
The console reporter logs a JSON object from all `QUnit.on()` reporting events. | ||
``` | ||
runStart {…} | ||
testStart {…} | ||
testEnd {…} | ||
testStart {…} | ||
testEnd {…} | ||
runEnd {…} | ||
``` | ||
groups: | ||
- reporters | ||
version_added: "2.3.0" | ||
--- | ||
|
||
The **console** reporter logs a JSON object from all [`QUnit.on`](../callbacks/QUnit.on.md) reporting events. | ||
|
||
Use this to explore or debug the [QUnit event emitter](../callbacks/QUnit.on.md). | ||
|
||
## Example | ||
|
||
``` | ||
runStart {…} | ||
testStart {…} | ||
testEnd {…} | ||
testStart {…} | ||
testEnd {…} | ||
runEnd {…} | ||
``` | ||
|
||
## Usage | ||
|
||
[QUnit CLI](../../cli.md#qunit-cli-options): | ||
|
||
```sh | ||
qunit --reporter console test/ | ||
``` | ||
|
||
Enable manually in JavaScript code (since QUnit 2.16): | ||
|
||
```js | ||
QUnit.reporters.console.init(QUnit); | ||
``` | ||
|
||
Enable declaratively via [QUnit.config](../config/index.md) (since QUnit 3.0): | ||
|
||
```js | ||
// Preconfig: | ||
// Set as environment variable to Node.js, | ||
// or as global variable before loading qunit.js | ||
qunit_config_reporters_console = true; | ||
|
||
// Config: Set from any inline script or JS file after qunit.js | ||
QUnit.config.reporters.console = true; | ||
``` | ||
|
||
## Changelog | ||
|
||
| UNRELEASED | Enable declaratively via [`QUnit.config.reporters`](../config/reporters.md). | ||
| [QUnit 2.16.0](/~https://github.com/qunitjs/qunit/releases/tag/2.16.0) | Exposed as `QUnit.reporters.perf` for programmatic usage. | ||
| [QUnit 2.3.0](/~https://github.com/qunitjs/qunit/releases/tag/2.3.0) | Introduced as part of the QUnit CLI and `--reporter console`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
layout: page-api | ||
title: QUnit.reporters.html | ||
excerpt: The HTML Reporter provides a toolbar, renders test results, diffs, and more. | ||
groups: | ||
- reporters | ||
version_added: "1.0.0" | ||
--- | ||
|
||
The **html** reporter renders a toolbar that lets you filter which modules or tests run, visualizes test results with diffs, provides "Rerun" links for individual tests, and more. This is enabled by default in [Browser](../../browser.md) environments | ||
|
||
The HTML Reporter is documented in detail at [Browser § HTML Reporter](../../browser.md#lead). | ||
|
||
## Usage | ||
|
||
By default, the [HTML Reporter](../../browser.md#lead) is automatically enabled in browser environments if a `<div id="qunit">` element exists. If such element doesn't exist, it remains disabled ("headless"). | ||
|
||
You can override this and disable the HTML Reporter even if the element does exist. For example, to share and reuse the same HTML file for CI, debugging, and manual testing; but disable the HTML Reporter in CI for improved performance. | ||
|
||
### Example | ||
|
||
```js | ||
// Preconfig: Set as global variable before loading qunit.js | ||
qunit_config_reporters_html = false; | ||
``` | ||
|
||
Or | ||
```js | ||
// Config: Set from any inline script or JS file after qunit.js | ||
QUnit.config.reporters.html = false; | ||
``` | ||
|
||
## Changelog | ||
|
||
| UNRELEASED | Toggle declaratively via [`QUnit.config.reporters`](../config/reporters.md). | ||
| [QUnit 1.0.0](/~https://github.com/qunitjs/qunit/releases/tag/1.0.0) | Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
layout: group | ||
group: reporters | ||
title: QUnit.reporters | ||
excerpt: Built-in reporters for TAP, HTML, console, and perf. | ||
amethyst: | ||
# Override inherited "pagetype: navigation" to enable Typesense indexing | ||
pagetype: custom | ||
robots: index | ||
--- | ||
|
||
To create your own reporter, refer to the [QUnit.on()](../callbacks/QUnit.on.md) event emitter and its Reporter API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
layout: page-api | ||
title: QUnit.reporters.perf | ||
excerpt: | | ||
The perf reporter measures each QUnit test, to then access or visualize in the browser devtools. | ||
<img alt="QUnit profiling in Chrome DevTools Performance tab" src="/resources/perf-chrome.png"> | ||
groups: | ||
- reporters | ||
version_added: "2.7.0" | ||
--- | ||
|
||
The **perf** reporter measures the duration of each QUnit test and each module, which you can then access in the browser dev tools to understand where time is spent during your test run. | ||
|
||
This uses the [performance.measure()](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure) method of the User Timing API, which adds each measure to the Performance Timeline. | ||
|
||
## Browser usage | ||
|
||
QUnit enables the perf reporter by default in [Browser](../../browser.md) environments. The measures are automatically included in Firefox Profiler and Chrome DevTools (Safari is pending [WebKit #213870](https://bugs.webkit.org/show_bug.cgi?id=213870)). | ||
|
||
``` | ||
QUnit Test Run | ||
└── QUnit Test Suite: Example | ||
├── QUnit Test: apple | ||
├── QUnit Test: banana | ||
└── QUnit Test: citron | ||
``` | ||
|
||
<figure> | ||
<img alt="QUnit profiling in Chrome DevTools Performance tab" src="/resources/perf-chrome.png"> | ||
<figcaption>Chrome</figcaption> | ||
</figure> | ||
|
||
------- | ||
|
||
<figure> | ||
<img alt="QUnit performance in Firefox Profiler" src="/resources/perf-firefox.png"> | ||
<figcaption>Firefox</figcaption> | ||
</figure> | ||
|
||
## Node.js usage | ||
|
||
The Web Performance API is also [available in Node.js](https://nodejs.org/docs/latest/api/perf_hooks.html), and the QUnit perf reporter can be enabled in Node.js since QUnit 3.0. | ||
|
||
You can enable it in the QUnit CLI via `--reporter perf`, or activate it explicitly from a [setup file](../../cli.md#--require) as: | ||
|
||
```js | ||
QUnit.reporters.perf.init(QUnit); | ||
``` | ||
|
||
**Note:** As of 2025, the [Node.js inspector](https://nodejs.org/docs/latest/api/debugger.html#v8-inspector-integration-for-nodejs) does not yet send User Timing measures to Chrome DevTools ([upstream nodejs/node#47813](/~https://github.com/nodejs/node/issues/47813)). | ||
|
||
This means that you _can_ retrieve the QUnit measures from [`performance.getEntries()`](https://nodejs.org/docs/latest/api/perf_hooks.html) and export or visualise them with tooling of your own (e.g. from a [runEnd event](../callback/QUnit.on.md##the-runend-event), or via a PerformanceObserver). | ||
|
||
But, when connecting Chrome DevTools to a Node.js process, these are not currently visualised. If you currently test frontend code for browsers via jsdom in Node.js, consider [testing in a real browser](../../browser.md) instead. | ||
|
||
## Changelog | ||
|
||
| UNRELEASED | Exposed separately via `qunit --reporter` on the CLI, via `QUnit.reporters.perf` for progammatic use in Node.js, and declaratively via [`QUnit.config.reporters`](../config/reporters.md). | ||
| [QUnit 2.7.0](/~https://github.com/qunitjs/qunit/releases/tag/2.7.0) | Introduced as part of the HTML Reporter, always enabled. |
Oops, something went wrong.