Stop defining a default QUnit.reset
See original GitHub issueSince we’re deprecating QUnit.reset
, we should stop relying on it. We could replicate the behavior almost perfectly by automatically registering a testDone
callback that includes the current logic, but executes it only when QUnit.reset === undefined
(or even !hasOwn.call(QUnit, "reset")
).
I say “almost perfectly” because the current code runs after all testDone
callbacks, but this proposal would have it run before them. This seems acceptable to me, but if it’s a problem we can explore a promise-based remedy.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
QUnit 2.0 Upgrade Guide
This guide will assist you in upgrading from QUnit 1 to QUnit 2. Overview. The QUnit 2 release only removes old methods. The...
Read more >How to stop Global Failures in qUnit? - Stack Overflow
In in qunit-2.3.2.js in the onError function before the line if(config.current.ignoreGlobalErrors) you can do this. Add the line config.current.
Read more >QUnit Advanced Concepts: Modules and Configuration
This article looks at modular design and configuration of the QUnit testing framework.
Read more >eslint-plugin-qunit - npm
ESLint plugin containing rules useful for QUnit tests.. Latest version: 7.3.4, last published: 14 days ago. Start using eslint-plugin-qunit ...
Read more >eslint-plugin-qunit | Yarn - Package Manager
ESLint plugin containing rules useful for QUnit tests. ... You can extend from a configuration in order to simplify manual configuration of plugin...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gibson042 this seems like a reasonable approach to me. I can take a crack at implementing it this weekend, if you don’t get to it by then.
It seems to me that legacy compatibility motivates us to automatically reset the DOM at test boundaries, even though such functionality is arguably more appropriate in a user-defined callback, e.g.
testStart
. But it should always be possible to correct the inverted default and prevent QUnit from doing anything. As of 0baf467d56735da6de22c377e991ec799460278a, the only way to do so is by removing#qunit-fixture
, which isn’t great. And when we consider the weirdness of a DOM coupling in test.js that is indirectly dependent upon the HTML reporter (for initial definition ofQUnit.config.fixture
), I think the best approach looks something like the following:QUnit.config.fixture
in core instead of the HTML reporter, still waiting for a “begin” event but aborting whenhasOwn.call( config, "fixture" )
to avoid overwriting user-provided values (evenundefined
ones).QUnit.config.fixture
as a public interface, in particular noting that it can be nulled to disable automatic DOM manipulation.QUnit.config.fixture == null
.QUnit.reset
, since we have at least one example of overwriting it and we don’t want silent failure to invoke it.This will preserve the legacy behavior of automatic inter-test DOM resets, but provide a documented means by which to control them, and reduce HTML reporter dependence to boot.