forked from qunitjs/qunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Support HTML/TAP preconfig via
QUnit.config.reporters
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
- Loading branch information
Showing
13 changed files
with
184 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
layout: page-api | ||
title: QUnit.config.reporters | ||
excerpt: Control which reporters to enable or disable. | ||
groups: | ||
- config | ||
redirect_from: | ||
- "/config/reporters/" | ||
version_added: "unreleased" | ||
--- | ||
|
||
Control which reporters to enable or disable. | ||
|
||
<table> | ||
<tr> | ||
<th>type</th> | ||
<td markdown="span">`object`</td> | ||
</tr> | ||
<tr> | ||
<th>default</th> | ||
<td markdown="span">`{}`</td> | ||
</tr> | ||
</table> | ||
|
||
## See also | ||
|
||
* [Preconfig](./index.md#preconfiguration) | ||
* [QUnit Reporter API](../callbacks/QUnit.on.md#reporter-api) | ||
|
||
## Built-in reporters | ||
|
||
### console | ||
|
||
The **console** reporter, logs a JSON object for each reporter event from [`QUnit.on`](./api/callbacks/QUnit.on.md). Use this to explore or debug the Reporter API. | ||
|
||
``` | ||
runStart {…} | ||
testStart {…} | ||
testEnd {…} | ||
testStart {…} | ||
testEnd {…} | ||
runEnd {…} | ||
``` | ||
|
||
### perf | ||
|
||
The **perf** reporter. | ||
|
||
### tap | ||
|
||
The **tap** reporter. | ||
|
||
### html | ||
|
||
The **html** reporter. | ||
|
||
## Examples | ||
|
||
By default, the HTML Reporter is enabled in browser environments if a `<div id="qunit">` element exists. You can [disable the HTML Reporter](../../browser.md). | ||
|
||
```js | ||
// | ||
QUnit.config.reporters.html = false; | ||
``` | ||
|
||
```js | ||
QUnit.config.reporters.html = true; | ||
``` |
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
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,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>config-reporters-html</title> | ||
<link rel="stylesheet" href="../../src/core/qunit.css"> | ||
<script> | ||
/* eslint-disable camelcase, no-undef */ | ||
// go headless | ||
qunit_config_reporters_html = false; | ||
// enable TAP | ||
qunit_config_reporters_tap = true; | ||
</script> | ||
<script src="../../qunit/qunit.js"></script> | ||
<script src="config-reporters-html.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
</body> | ||
</html> |
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,14 @@ | ||
/* eslint-env browser */ | ||
QUnit.module('QUnit.config.reporters'); | ||
|
||
QUnit.test('read config', function (assert) { | ||
assert.deepEqual(QUnit.config.reporters, { | ||
html: false, | ||
tap: true | ||
}); | ||
}); | ||
|
||
QUnit.test('HtmlReporter disabled', function (assert) { | ||
var children = [].slice.call(document.querySelectorAll('#qunit > *')); | ||
assert.deepEqual(children, [], '#qunit element is empty'); | ||
}); |