-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate HTML runner and HTML reporter? #1118
Comments
I like this, and note also the (loosely) related #947. |
I'm looking into this as part of #1486, and running into an obstacle with For QUnit's own use, we could trivially generate a different set of IDs (e.g. lazily, from the testStart event). For plugins, we may need to change it so that the plugin reacts to the HTML rather than influencing it from the inside. For example, the way a plugin finds the HTML element currently is via (contextual) Straw-man proposal:
Challenges this brings about:
Perhaps it's not worth separating the two, but we could still add support for disabling the bulk of the output and running a plain text CRI reporter in its place. In any event, that could of course be a good first step either way. |
Used by HTML Reporter, and by plugins such as `steal-qunit`. Ref qunitjs#1118
Used by HTML Reporter, and by plugins such as `steal-qunit`. Ref #1118
As prep to extract a reporter-agnostic "HTML Runner" from the HTML Reporter, move the `urlparams.js` import out of html.js. It is important (and covered by `test/reporter-html/hidepassed.html`) that the `QUnit.begin()` callback in urlparams.js continues to run before the one in html.js. When only moving the import statement, this breaks because diff.js was also importing html.js for re-use of the `escapeText` function. As such the order in reporter.js was not what it appeared. It appeared as: - fixture - diff - html - urlparams But was actually: - fixture - diff - html - urlparams - html (redundant) Ref #1118
=== What === Turn html.js into an HtmlReporter class where the HtmlReporter.init static method contains (most) of the browser runner logic that we would run even if the HtmlReporter were turned off. This patch primarily deals with making html.js itself free of side-effects by delaying any browser setup logic to the init() function. In a future patch we can take this further and move the logic to a "browser runner" function of sorts, such that what is left in the reporter can be made conditional on the presence of `div[id=qunit]` and/or `QUnit.config.reporters.html`. This is tracked in qunitjs#1118 and qunitjs#1711. Ref qunitjs#1486. === Why === We need html.js to be side-effect free in order to add native ESM support, tracked at qunitjs#1551. To support native ESM exports, we need to introduce a separate distribution file since ESM export syntax isn't allowed in scripts. I expect numerous projects to involve mixed ESM imports and CJS require usage, especially when integration layers and plugins are involved. To avoid a split-brain problem, this means we need to somehow have both export the same one. The way I intend to do this is by detecting if QUnit was already defined, and if so, discard our local definition and use that one instead. This means we need to only init the browser runner only if we're the first one (e.g. window.onerror, QUnit.begin for fixture, QUnit.testDone for HTML reporting, etc). To accomplish that, start by making html.js side-effect free, deferring its init code to a (for now) unconditional call at the end of qunit.js.
=== What === Turn html.js into an HtmlReporter class where the HtmlReporter.init static method contains (most) of the browser runner logic that we would run even if the HtmlReporter were turned off. This patch primarily deals with making html.js itself free of side-effects by delaying any browser setup logic to the init() function. In a future patch we can take this further and move the logic to a "browser runner" function of sorts, such that what is left in the reporter can be made conditional on the presence of `div[id=qunit]` and/or `QUnit.config.reporters.html`. This is tracked in qunitjs#1118 and qunitjs#1711. Ref qunitjs#1486. === Why === We need html.js to be side-effect free in order to add native ESM support, tracked at qunitjs#1551. To support native ESM exports, we need to introduce a separate distribution file since ESM export syntax isn't allowed in scripts. I expect numerous projects to involve mixed ESM imports and CJS require usage, especially when integration layers and plugins are involved. To avoid a split-brain problem, this means we need to somehow have both export the same one. The way I intend to do this is by detecting if QUnit was already defined, and if so, discard our local definition and use that one instead. This means we need to only init the browser runner only if we're the first one (e.g. window.onerror, QUnit.begin for fixture, QUnit.testDone for HTML reporting, etc). To accomplish that, start by making html.js side-effect free, deferring its init code to a (for now) unconditional call at the end of qunit.js.
=== What === Turn html.js into an HtmlReporter class where the HtmlReporter.init static method contains (most) of the browser runner logic that we would run even if the HtmlReporter were turned off. This patch primarily deals with making html.js itself free of side-effects by delaying any browser setup logic to the init() function. In a future patch we can take this further and move the logic to a "browser runner" function of sorts, such that what is left in the reporter can be made conditional on the presence of `div[id=qunit]` and/or `QUnit.config.reporters.html`. This is tracked in qunitjs#1118 and qunitjs#1711. Ref qunitjs#1486. === Why === We need html.js to be side-effect free in order to add native ESM support, tracked at qunitjs#1551. To support native ESM exports, we need to introduce a separate distribution file since ESM export syntax isn't allowed in scripts. I expect numerous projects to involve mixed ESM imports and CJS require usage, especially when integration layers and plugins are involved. To avoid a split-brain problem, this means we need to somehow have both export the same one. The way I intend to do this is by detecting if QUnit was already defined, and if so, discard our local definition and use that one instead. This means we need to only init the browser runner only if we're the first one (e.g. window.onerror, QUnit.begin for fixture, QUnit.testDone for HTML reporting, etc). To accomplish that, start by making html.js side-effect free, deferring its init code to a (for now) unconditional call at the end of qunit.js.
=== What === Turn html.js into an HtmlReporter class where the HtmlReporter.init static method contains (most) of the browser runner logic that we would run even if the HtmlReporter were turned off. This patch primarily deals with making html.js itself free of side-effects by delaying any browser setup logic to the init() function. In a future patch we can take this further and move the logic to a "browser runner" function of sorts, such that what is left in the reporter can be made conditional on the presence of `div[id=qunit]` and/or `QUnit.config.reporters.html`. This is tracked in #1118 and #1711. Ref #1486. Intentional changes: * Use of previousFailure is no longer conditional on QUnit.config.reorder in order to make it more stateless. The message already did not state that it relates to config.reorder, and stating that it previously failed is accurate either way. * Calling ev.preventDefault() is no longer conditional. This has been supported since IE9. QUnit 2 already required IE9+, and QUnit 3.0 will require IE11. jQuery removed similar check in jQuery 2.2.0, with commit jquery/jquery@a873558436. === Why === We need html.js to be side-effect free in order to add native ESM support, tracked at #1551. To support native ESM exports, we need to introduce a separate distribution file since ESM export syntax isn't allowed in scripts. I expect numerous projects to involve mixed ESM imports and CJS require usage, especially when integration layers and plugins are involved. To avoid a split-brain problem, this means we need to somehow have both export the same one. The way I intend to do this is by detecting if QUnit was already defined, and if so, discard our local definition and use that one instead. This means we need to only init the browser runner only if we're the first one (e.g. window.onerror, QUnit.begin for fixture, QUnit.testDone for HTML reporting, etc). To accomplish that, start by making html.js side-effect free, deferring its init code to a (for now) unconditional call at the end of qunit.js.
This refactors the initFixture and initUrlconfig code to be an exported callable so that it is safe to define without side-effects and can then be called conditionally. The previous code was already conditionally with an inline check for window/document. This is now centralised in prep for making it further conditional on whether or not QUnit was already exported, thus making it safe to load QUnit twice (e.g. ESM and CJS without split-brain conflict). Tracked at #1551. Follows-up e1e03e6. Closes #1118.
This restores the first half of the Cookbook that Jörn originally wrote on the original qunitjs.com website. We removed this during the redesign in 2020, but we hadn't found a new place for everything. qunitjs/qunitjs.com#151 https://github.com/qunitjs/qunitjs.com/blob/v2.10.2/pages/cookbook.html * Update config doc pages to reflect whether something is part of Browser Runner (active in any browser environment), or the HTML Reporter. These have been separated now per #1118, as QUnit.reporters.html, and deals purely with what happens inside the optional `div[id=qunit]` element. * Move browser-related content from intro.md to the new browser.md. We should probably do the same for Node.js/CLI as well, and focus this only on env-agnostic getting started. This would be easier if the example use export/import ESM instead of having to assume either module.exports (Node.js) or globals (browser). Co-authored-by: Jörn Zaefferer <[email protected]> Fixes #1748. Fixes #1747.
This restores the first half of the Cookbook that Jörn originally wrote on the original qunitjs.com website. We removed this during the redesign in 2020, but we hadn't found a new place for everything. qunitjs/qunitjs.com#151 https://github.com/qunitjs/qunitjs.com/blob/v2.10.2/pages/cookbook.html * Update config doc pages to reflect whether something is part of Browser Runner (active in any browser environment), or the HTML Reporter. These have been separated now per #1118, as QUnit.reporters.html, and deals purely with what happens inside the optional `div[id=qunit]` element. * Move browser-related content from intro.md to the new browser.md. We should probably do the same for Node.js/CLI as well, and focus this only on env-agnostic getting started. This would be easier if the example use export/import ESM instead of having to assume either module.exports (Node.js) or globals (browser). Co-authored-by: Jörn Zaefferer <[email protected]> Fixes #1748. Fixes #1747.
This restores the first half of the Cookbook that Jörn originally wrote on the original qunitjs.com website. We removed this during the redesign in 2020, but we hadn't found a new place for everything. qunitjs/qunitjs.com#151 https://github.com/qunitjs/qunitjs.com/blob/v2.10.2/pages/cookbook.html * Update config doc pages to reflect whether something is part of Browser Runner (active in any browser environment), or the HTML Reporter. These have been separated now per #1118, as QUnit.reporters.html, and deals purely with what happens inside the optional `div[id=qunit]` element. * Move browser-related content from intro.md to the new browser.md. We should probably do the same for Node.js/CLI as well, and focus this only on env-agnostic getting started. This would be easier if the example use export/import ESM instead of having to assume either module.exports (Node.js) or globals (browser). Fixes #1748. Fixes #1747. Co-authored-by: Jörn Zaefferer <[email protected]>
(Ditching the issue template since this is a meta-issue)
Now that we're working on a QUnit Node CLI and integrating with js-reporters, I think we need to see if we can refactor the HTML Reporter space to split that into HTML "runner" and HTML "reporter".
Conceptually, here is what I would like to see long-term:
The text was updated successfully, but these errors were encountered: