-
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
feat: disable html reporter entirely for headless CI #1711
Comments
@runspired Can you try removing the |
I ended up using pnpm patch to rewrite a small bit to enable this. Can put up a PR with that if you're interested, more just to see than to push forward. |
@runspired Are you using an additional package for this? The HTML Reporter element is populated, but not created, by QUnit. It is typically declared in your As mentioned, we'll make this easier in the next release, but I'm checking to make sure I understand what you needed to patch and whether there's a way I can document today that doesn't involve a patch. |
We're using it with testem and ember. The same html file gets re-used in both CI and browser. We could potentially find a way to juggle the launch file, but it's a bit hefty and I think the easier lift for us is going to be to either upstream the ability to disable it (as we've found this useful even in-browser for memory-leak testing) or to continue patching (it's a fairly tiny patch). |
@runspired If we introduced an option like When using Testem standalone (see test/integration), a bridge script must be loaded from the |
=== 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.
…upport * Expose `options.element` as injectable constructor option. * If not given, and if no element exists by runStart event, then don't listen to any events. This should make headless execution significantly faster. Ref qunitjs#1711. * As proof of concept, convert one of the HTML Reporter tests to use this injection approach, thus proving that the class no longer relies on any global state, and can be tested as a constructable instance, without the global runner having to be dedicated to the same test scenario. In future patches, I hope to convert more of the HTML Reporter tests to be simply test functions in test/main/ that can be run all together instead of requiring separate page loads.
…upport * Expose `options.element` as injectable constructor option. * If not given, and if no element exists by runStart event, then don't listen to any events. This should make headless execution significantly faster. Ref qunitjs#1711. * As proof of concept, convert one of the HTML Reporter tests to use this injection approach, thus proving that the class no longer relies on any global state, and can be tested as a constructable instance, without the global runner having to be dedicated to the same test scenario. In future patches, I hope to convert more of the HTML Reporter tests to be simply test functions in test/main/ that can be run all together instead of requiring separate page loads.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
Allow disabling of HTML Reporter even if `<div id="qunit">` exists. Ref qunitjs#1711.
memory growth over time for the html reporter still occurs even when hidepassed is true as the hidden DOM nodes are retained. For test suites with massive quantities of tests this can have a significant effect.
The text was updated successfully, but these errors were encountered: