<div dir="ltr"><div>TL;DR:</div><div>    MediaWiki core is upgrading its version of QUnit from 1.x to 2.x.</div><div>    This means extensions or skins with QUnit tests must now be compatible with 2.x.</div><div>    See <a href="https://phabricator.wikimedia.org/T170515">https://phabricator.wikimedia.org/T170515</a> and <a href="https://qunitjs.com/upgrade-guide-2.x/">https://qunitjs.com/upgrade-guide-2.x/</a>.</div><div><br></div><div>Hi all,</div><div><br></div><div>### Deprecated API</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>For a short list of removed functions, see <a href="https://phabricator.wikimedia.org/T170515">https://phabricator.wikimedia.org/T170515</a>.</div><div><br></div><div>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", </div><div><br></div><div>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.</div><div><br></div><div>See <a href="https://qunitjs.com/upgrade-guide-2.x/">https://qunitjs.com/upgrade-guide-2.x/</a>.</div><div><br></div><div>### New features</div><div><br></div><div>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().</div><div><br></div><div>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.</div><div><br></div><div>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() handler.</div><div><br></div><div>## Upgrade</div><div><br></div><div>The version used on Special:JavaScriptTest has already been upgraded. – <a href="https://gerrit.wikimedia.org/r/365757">https://gerrit.wikimedia.org/r/365757</a>.</div><div><br></div><div>The copy used for command-line usage (grunt-karma) and Jenkins will be upgraded by <a href="https://gerrit.wikimedia.org/r/367838">https://gerrit.wikimedia.org/r/367838</a></div><div><br></div><div>-- Timo</div></div>