[QA] Upgrade of QUnit from 1.x to 2.x is underway

Krinkle krinklemail at gmail.com
Thu Jul 27 01:26:39 UTC 2017

    MediaWiki core is upgrading its version of QUnit from 1.x to 2.x.
    This means extensions or skins with QUnit tests must now be compatible
with 2.x.
    See https://phabricator.wikimedia.org/T170515 and

Hi all,

### Deprecated API

In 2014, QUnit started to overhaul its API, to be more robust and better
support async workflows. The most notable change was the removal of global
and static functions, in favour of more contextual methods.

The first part of this released in 1.15, and more was gradually introduced
in later releases. The vast majority of our codebases are already using the
new interfaces. In fact, the vast majority of our QUnit tests were written
after 2014 and never used the old interfaces in the first place.

For a short list of removed functions, see

If you find a QUnit Jenkins job for a MediaWiki extension or skin repo
starts failing, it is most likely due to this. Look for errors such as
"QUnit.start undefined", "test.callback is not a function",
"QUnit.asyncTest is undefined", and "QUnit.push is undefined",

There are also some methods that have been deprecated over the past few
years. These still work in QUnit 2. Please take a moment to familiarise
yourself with the renamed methods and new methods. Doing so will avoid
confusion when reading new code that uses them.

See https://qunitjs.com/upgrade-guide-2.x/.

### New features

The 'setup' and 'teardown' module hooks are now called 'beforeEach' and
'afterEach'. The old names still work, but the new names clarify that these
hooks are run for each QUnit.test().

QUnit 2.0 also adds new 'before' and 'after' hooks, which run only once per
module. This is somewhat analogous to use of setUpBeforeClass() in PHPUnit.

Since QUnit 1.16, QUnit.test() supports returning a Promise from the test
callback. This automatically attaches an assert.async() handler and waits
for the promise to complete. It also asserts that the Promise will be
resolved, and fails the test if rejected. This helps avoid a common pitfal
where a test could timeout when forgetting to attach a promise.fail()

## Upgrade

The version used on Special:JavaScriptTest has already been upgraded. –

The copy used for command-line usage (grunt-karma) and Jenkins will be
upgraded by https://gerrit.wikimedia.org/r/367838

-- Timo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/qa/attachments/20170726/9db42914/attachment.html>

More information about the QA mailing list