question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stop defining a default QUnit.reset

See original GitHub issue

Since 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:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
trentmwilliscommented, Apr 28, 2016

@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.

0reactions
gibson042commented, Apr 20, 2016

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 of QUnit.config.fixture), I think the best approach looks something like the following:

  • Initialize QUnit.config.fixture in core instead of the HTML reporter, still waiting for a “begin” event but aborting when hasOwn.call( config, "fixture" ) to avoid overwriting user-provided values (even undefined ones).
  • Document QUnit.config.fixture as a public interface, in particular noting that it can be nulled to disable automatic DOM manipulation.
  • Skip DOM resets when QUnit.config.fixture == null.
  • Throw an exception upon setting of 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found