Skip to content

Commit 734c71d

Browse files
committed
[DRAFT] Docs: "Early errors" and "New theme" blog posts
1 parent d3aab08 commit 734c71d

8 files changed

Lines changed: 134 additions & 5 deletions

File tree

History.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* HTML Reporter: New design with fresh color palette and improved color contrast. View demos in [#1774](https://github.com/qunitjs/qunit/pull/1774).
2121
* Faster UI rendering, now instantly instead of after DOM-ready. [#1793](https://github.com/qunitjs/qunit/pull/1793)
2222
* Faster headless execution, when [`id=qunit` element](https://qunitjs.com/browser/) does not exist. [#1711](https://github.com/qunitjs/qunit/issues/1711)
23+
* Faster "Hide passed" toggling on large test suites. [a729421411](https://github.com/qunitjs/qunit/commit/a7294214116ab5ec0e111b37c00cc7e2c16b4e1b)
2324
* Add support for displaying early errors. [#1786](https://github.com/qunitjs/qunit/pull/1786)
2425
* Change assertion count in toolbar to test count. [#1760](https://github.com/qunitjs/qunit/pull/1760)
2526
* Change `#qunit-banner` from H2 to DIV, to fix WCAG compliance. [#1427](https://github.com/qunitjs/qunit/issues/1427)
@@ -36,7 +37,7 @@
3637
* Core: Fix internal `QUnit.config.currentModule` for the initial unnamed module to be a complete object. [5812597b7f](https://github.com/qunitjs/qunit/commit/5812597b7f086e6afafef947ebff5231c0011f6b)
3738
* Core: Fix crash when "bad thenable" is returned from global module hook. [3209462b88](https://github.com/qunitjs/qunit/commit/3209462b88)
3839
* Core: Fix crash when mixing test.only() with module.only(). [99aee51a8a](https://github.com/qunitjs/qunit/commit/99aee51a8a4dfce3fa87559e171398fdf72c6886)
39-
* Core: Fix [QUnit.config.maxDepth](https://qunitjs.com/api/config/maxDepth/) to allow changes at runtime. QUnit.dump.maxDepth is now a live alias to `QUnit.config.maxDepth`. [0a26e2c883](https://github.com/qunitjs/qunit/commit/0a26e2c883ab49831b19ebc34a4b7caac573d995) test suites. [a729421411](https://github.com/qunitjs/qunit/commit/a7294214116ab5ec0e111b37c00cc7e2c16b4e1b)
40+
* Core: Fix [QUnit.config.maxDepth](https://qunitjs.com/api/config/maxDepth/) to allow changes at runtime. QUnit.dump.maxDepth is now a live alias to `QUnit.config.maxDepth`. [0a26e2c883](https://github.com/qunitjs/qunit/commit/0a26e2c883ab49831b19ebc34a4b7caac573d995) test suites.
4041

4142
### Removed
4243

docs/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ source "https://rubygems.org"
22
ruby RUBY_VERSION
33

44
# To apply changes, run `bundle update`.
5-
gem "jekyll-theme-amethyst", "2.11.0", group: :jekyll_plugins
5+
gem "jekyll-theme-amethyst", "2.11.1", group: :jekyll_plugins
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
layout: post
3+
title: "Early error reporting"
4+
author: krinkle
5+
excerpt: Early errors.
6+
tags:
7+
- feature
8+
---
9+
10+
## What is an "early" error?
11+
12+
Early errors are errors when loading source code or test files, outside and before the first test.
13+
14+
For example, a syntax error in a source file. Or an uncaught error while defining exports from your source files. Or an early error from a test file, such as if you misspell an import, or call an undefined function in top-level code outside your [`QUnit.test()`]({% link api/QUnit/test.md %}) cases.
15+
16+
## Status quo
17+
18+
In both QUnit 1.x and 2.x, "early" errors are reporter to the browser console, but not displayed in the UI of the HTML Reporter.
19+
20+
Until now, the HTML Reporter initialized the UI during the [`QUnit.begin()`]({% link api/callbacks/QUnit.begin.md %}) event. This fires after your source and test files are loaded, before the first test begins. This approach is **simple** and **robust**.
21+
22+
We generally recommend loading styles from the HTML head, and scripts from the end of the body:
23+
24+
```html
25+
<!DOCTYPE html>
26+
<html>
27+
<head>
28+
<meta charset="utf-8">
29+
<title>QUnit</title>
30+
<link rel="stylesheet" href="lib/qunit/qunit.css">
31+
</head>
32+
<body>
33+
<div id="qunit"></div>
34+
35+
<script src="lib/qunit/qunit.js"></script>
36+
<!-- <script src="src/my_project.js"></script> -->
37+
<!-- <script src="test/my_project.test.js"></script> -->
38+
</body>
39+
</html>
40+
```
41+
42+
But, QUnit works regardless of HTML order. Older projects often load scripts from the HTML `<head>`, before the `<div id="qunit">` element. Like so:
43+
44+
```html
45+
<!DOCTYPE html>
46+
<html>
47+
<head>
48+
<meta charset="utf-8">
49+
<title>QUnit</title>
50+
<link rel="stylesheet" href="lib/qunit/qunit.css">
51+
<script src="lib/qunit/qunit.js"></script>
52+
<!-- <script src="src/my_project.js"></script> -->
53+
<!-- <script src="test/my_project.test.js"></script> -->
54+
</head>
55+
<body>
56+
<div id="qunit"></div>
57+
</body>
58+
</html>
59+
```
60+
61+
Initializing the UI from a `QUnit.begin()` event, is akin to waiting for the DOM-ready or `window.onload` event, and means we simply look for the `<div id="qunit">` element and either safely append the UI, or decide definitively that we're running headless with the UI [turned off]({% link api/reporters/html.md %}).
62+
63+
However, this also meant that if we receive an early `error` event, the page remains blank.
64+
65+
66+
[`error` event]({% link api/callbacks/QUnit.on.md %}#the-error-event)
67+
68+
69+
70+
## Instant rendering
71+
72+
73+
74+
## See also
75+
76+
* [QUnit 2.24.1 Released: Add memory to the "error" event]({% post_url 2025-01-25-qunit-2-24-1 %})
77+
* [Add support for displaying early errors · Pull Request #1786](https://github.com/qunitjs/qunit/pull/1786)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
layout: post
3+
title: "New theme for QUnit 3"
4+
author: krinkle
5+
excerpt: Faster rendering, accessibility improvements, and a fresh color palette.
6+
tags:
7+
- feature
8+
---
9+
10+
QUnit 3 comes with a new design for the HTML Reporter, featuring improved color contrast, and a fresh color palette.
11+
12+
## Accessility
13+
14+
Color contrast.
15+
16+
Change `#qunit-banner` from H2 to DIV, to fix WCAG compliance. [#1427](https://github.com/qunitjs/qunit/issues/1427)
17+
18+
Change `#qunit-testresult` from P to DIV, to fix HTML serialization. [#1301](https://github.com/qunitjs/qunit/issues/1301)
19+
20+
Fix color constrast of details in failed test results. [#1803](https://github.com/qunitjs/qunit/pull/1803)
21+
22+
## Instant rendering
23+
24+
Faster UI rendering, now instantly instead of after DOM-ready. [#1793](https://github.com/qunitjs/qunit/pull/1793).
25+
26+
## Edge-to-edge design
27+
28+
29+
30+
## Fresh color pallete
31+
32+
33+
34+
## Headless optimization
35+
36+
Faster headless execution, when [`id=qunit` element](https://qunitjs.com/browser/) does not exist. [#1711](https://github.com/qunitjs/qunit/issues/1711)
37+
38+
Faster "Hide passed" toggling on large test suites. [a729421411](https://github.com/qunitjs/qunit/commit/a7294214116ab5ec0e111b37c00cc7e2c16b4e1b)
39+
40+
## Misc
41+
42+
* HTML Reporter: New design with fresh color palette and improved color contrast. View demos in [#1774](https://github.com/qunitjs/qunit/pull/1774).
43+
* Add support for displaying early errors. [#1786](https://github.com/qunitjs/qunit/pull/1786)
44+
* Change assertion count in toolbar to test count. [#1760](https://github.com/qunitjs/qunit/pull/1760)
45+
* Change runtime in toolbar from milliseconds to seconds. [#1760](https://github.com/qunitjs/qunit/pull/1760)
46+
* Fix text selection to exclude "Rerun" link. [6becc199e0](https://github.com/qunitjs/qunit/commit/6becc199e0)
47+
* Fix overflow and scrollbar issues. [#1603](https://github.com/qunitjs/qunit/issues/1603)

docs/api/callbacks/QUnit.begin.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ The callback will be called once, before QUnit runs any tests.
3333
| [QUnit 1.16](https://github.com/qunitjs/qunit/releases/tag/1.16.0) | Added `details.modules` property, containing `{ name: string }` objects.
3434
| [QUnit 1.15](https://github.com/qunitjs/qunit/releases/tag/1.15.0) | Added `details.totalTests` property.
3535

36+
## See also
37+
38+
* [`QUnit.start()`](../QUnit/start.md)
39+
3640
## Examples
3741

3842
Get total number of tests known at the start.

docs/browser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Example projects:
118118

119119
QUnit requires no HTML markup in order to run tests. The above "Getting started" example is recommended for new projects, but you can customize this as-needed.
120120

121-
To display test results, the only markup necessary is a `<div>` with `id="qunit"`. Without this, the tests will run with the [HTML Reporter](#html-reporter) disabled.
121+
To display test results, the only markup necessary is a `<div>` with `id="qunit"`. Without this, the tests will run headless with the [HTML Reporter disabled](./api/reporters/html.md).
122122

123123
[Browser automations](#integrations) that run tests for you from the command-line, might enable other reporters or event listeners instead. For example, they might use a [TAP reporter](./api/reporters/tap.md), or [`QUnit.on()`](./api/callbacks/QUnit.on.md) to automatically extract results in a machine-readable way, and use it to set the build status of a continuous integration job (CI).
124124

src/core/qunit-wrapper-bundler-require.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// In a single bundler invocation, if different parts or dependencies
44
// of a project mix ESM and CJS, avoid a split-brain state by making
5-
// sure both import and re-use the same instance via this wrapper.
5+
// sure "import" and "require" re-use the same instance via this wrapper.
66
//
77
// Bundlers generally allow requiring an ESM file from CommonJS.
88
const { QUnit } = require('./esm/qunit.module.js');

src/core/qunit-wrapper-nodejs-module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// In a single Node.js process, if different parts or dependencies
22
// of a project mix ESM and CJS, avoid a split-brain state by making
3-
// sure both import and re-use the same instance via this wrapper.
3+
// sure "import" and "require" re-use the same instance via this wrapper.
44
//
55
// Node.js 12+ can import a CommonJS file from ESM.
66
import QUnit from '../qunit.js';

0 commit comments

Comments
 (0)