Skip to content

Docs: Write "Test lifecycle" page and add diagram#1806

Merged
Krinkle merged 1 commit intoqunitjs:mainfrom
Krinkle:docs
Apr 3, 2025
Merged

Docs: Write "Test lifecycle" page and add diagram#1806
Krinkle merged 1 commit intoqunitjs:mainfrom
Krinkle:docs

Conversation

@Krinkle
Copy link
Member

@Krinkle Krinkle commented Apr 3, 2025

Test lifecycle

  • New example demonstrating module options being copied to context.

QUnit.module § Hooks

  • Rewrite to be more example-driven.

  • Move existing examples inline, and simplify examples a lot.

Move low-level ordering details to the new "Test lifecycle" page. For most readers these are a technically-worded distraction that underminss the naturally correct intuition one would otherwise assume, and wrongly give the impression that there is something unique or complicated here.

The way QUnit works is comparable to other test frameworks, both those that came before (e.g. PHPUnit, Python unittest), and those that followed (e.g. Jasmine, Mocha).

Besides, most projects tend to define tests with 0 or 1 hooks, where ordering or inheritence isn't observable. Even when a larger ecosystem, like Ember or MediaWiki, is involved, their global hooks and utilities work as expected without contributors needing to be aware of where they come from. It just works!

QUnit.module § Options

Promote the shorter object literal "method" syntax (ES6).

QUnit.module § Examples

  • "Async hook callback", moved inline.

  • "Hooks on nested modules", moved to Test lifecycle page.

  • "Hooks via module options", moved inline.

  • "Using the test context", moved QUnit.test page, with a copy on the Test lifecycle page as well.

  • "Only run a subset of tests"

    • rename to "Skip a module",
    • re-arrange to lead with "QUnit.module.skip" instead of obscure "todo" and "only".
    • add new example for QUnit.module.if().

== Test lifecycle ==

* New diagram!

* New example demonstrating module options being copied to context.

== QUnit.module § Hooks ==

* Rewrite to be more example-driven.

* Move existing examples inline, and simplify examples a lot.

Move low-level ordering details to the new "Test lifecycle" page.
For most readers these are a technically-worded distraction that
underminss the naturally correct intuition one would otherwise assume,
and wrongly give the impression that there is something unique or
complicated here.

The way QUnit works is comparable to other test frameworks, both
those that came before (e.g. PHPUnit, Python unittest), and those
that followed (e.g. Jasmine, Mocha).

Besides, most projects tend to define tests with 0 or 1 hooks,
where ordering or inheritence isn't observable. Even when a larger
ecosystem, like Ember or MediaWiki, is involved, their global hooks
and utilities work as expected without contributors needing to be
aware of where they come from. It just works!

== QUnit.module § Options ==

Promote the shorter object literal "method" syntax (ES6).

== QUnit.module § Examples ==

* "Async hook callback", moved inline.

* "Hooks on nested modules", moved to Test lifecycle page.

* "Hooks via module options", moved inline.

* "Using the test context", moved QUnit.test page, with a copy
  on the Test lifecycle page as well.

* "Only run a subset of tests"
  - rename to "Skip a module",
  - re-arrange to lead with "QUnit.module.skip" instead of obscure
    "todo" and "only".
  - add new example for `QUnit.module.if()`.

Closes qunitjs#1358.

Co-authored-by: FND <fnd@localhost.localdomain>
Co-authored-by: jdittrich <d_jan@ymail.com>
@Krinkle Krinkle merged commit 0476465 into qunitjs:main Apr 3, 2025
10 checks passed
@Krinkle Krinkle deleted the docs branch April 3, 2025 06:38
@FND
Copy link
Contributor

FND commented Apr 3, 2025

@Krinkle: I appreciate you following up on this!

I have two minor observations:

  • It took me a little while to understand that on the left-hand side, QUnit.module("…", was unclosed by design rather than an unintentional syntax error. I now get why that's the case, so just from my entirely subjective POV, this leaves me with some tension - though admittedly, I don't have a great solution (other than crutches like QUnit.module("Parent", …) or QUnit.module("Parent", ┕┅┅┅┅┙) perhaps).
  • I was positively surprised that you went to the trouble of supporting dark mode in the SVG. Within the surrounding page, that results in the diagram's borders blending with the edge (see screenshot below) - that might be improved with some padding?

screenshot of the diagram in dark mode embedded within the aforementioned page

Krinkle added a commit to Krinkle/qunit that referenced this pull request Apr 3, 2025
Source on diagrams.net:
https://drive.google.com/file/d/1PJ2nDZkiOreCHzH_PyQRImiH7Z0eoR8F/view?usp=sharing

Export:
* Export as SVG
* Zoom: 100%
* Border: 10
* Everythign off (Transparent, Shadow, Include diagram, Embed Fonts)

Post-processing for diagrams.net bugs:
* Remove any remnant `@import` for unused Google Font references.
* `&quot;Arial&quot;`     -> system-ui,sans-serif
* `&quot;monospace&quot;` -> monospace

Ref qunitjs#1806.

Co-authored-by: FND <fnd@localhost.localdomain>
@Krinkle
Copy link
Member Author

Krinkle commented Apr 3, 2025

@FND I'm actually as surprised as you are (I prefer light mode on desktop). I didn't realize Diagrams.net produces a dark mode version by default. (https://en.wikipedia.org/wiki/Diagrams.net, https://github.com/jgraph/drawio/).

Indeed, Firefox and Chrome appear to let the color-scheme of an HTML document bleed into the computed CSS value, such as light-dark(), even for embedded SVGs in <img> tags. Interesting!

Safari does not support this yet.

I've revised the diagram at #1807.

@FND
Copy link
Contributor

FND commented Apr 3, 2025

TIL! I'll need to look into this more closely sometime... Thanks for looking up those WebKit links!

Krinkle added a commit that referenced this pull request Apr 3, 2025
Source on diagrams.net:
https://drive.google.com/file/d/1PJ2nDZkiOreCHzH_PyQRImiH7Z0eoR8F/view?usp=sharing

Export:
* Export as SVG
* Zoom: 100%
* Border: 10
* Everythign off (Transparent, Shadow, Include diagram, Embed Fonts)

Post-processing for diagrams.net bugs:
* Remove any remnant `@import` for unused Google Font references.
* `&quot;Arial&quot;`     -> system-ui,sans-serif
* `&quot;monospace&quot;` -> monospace

Ref #1806.

Co-authored-by: FND <fnd@localhost.localdomain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants