TL;DR: 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 https://qunitjs.com/upgrade-guide-2.x/.
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 https://phabricator.wikimedia.org/T170515.
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() handler.
## Upgrade
The version used on Special:JavaScriptTest has already been upgraded. – https://gerrit.wikimedia.org/r/365757.
The copy used for command-line usage (grunt-karma) and Jenkins will be upgraded by https://gerrit.wikimedia.org/r/367838
-- Timo
The upgrade to QUnit 2 is now complete and the last part of it landed in MediaWiki core master earlier this week. [1]
Thanks for the many efforts from everyone who helped migrate the tests in our repositories!
Care was taken to make sure all extensions involved in the MediaWiki extension gate Jenkins job are passing. If you notice that starting today, a QUnit job is no longer passing, check out the migration guide at https://qunitjs.com/upgrade-guide-2.x/ and our summary at https://phabricator.wikimedia.org/T170515. If you're having trouble fixing the build, feel free to reach out on IRC to James Forrester or myself.
-- Timo Tijhof (Krinkle)
[1] https://gerrit.wikimedia.org/r/#/c/367838/
On Thu, Jul 27, 2017 at 2:26 AM, Krinkle krinklemail@gmail.com wrote:
TL;DR: 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 https://qunitjs.com/upgrade-guide-2.x/.
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 https://phabricator.wikimedia. org/T170515.
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() handler.
## Upgrade
The version used on Special:JavaScriptTest has already been upgraded. – https://gerrit.wikimedia.org/r/365757.
The copy used for command-line usage (grunt-karma) and Jenkins will be upgraded by https://gerrit.wikimedia.org/r/367838
-- Timo
wikitech-l@lists.wikimedia.org