Page MenuHomePhabricator

Provide standard way to create/run QUnit tests for Gadgets and user scripts
Open, LowPublic

Description

I was thinking about creating some QUnit tests for one of my user scripts and also for a gadget, but AFAIK there is no standard way to do this.

The [[Special:JavaScriptTest/qunit]] only says "This function has not been enabled on this wiki." but maybe it should provide a way to let users to run their QUnit tests, e.g. by defining the page name of a script, or some URL param.

For example, if a wiki has some gadgets the users (mainly sysops and gadget editors) could follow links to pages such as
[[Special:JavaScriptTest/qunit/<some name related to the gadget>]]
(or use a URL param, as in "Special:JavaScriptTest/qunit?gadget=foo") as soon as a gadget is changed, to ensure the latest changes didn't broke anything.

See Also:

Details

Reference
bz37230

Related Objects

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:30 AM
bzimport set Reference to bz37230.
bzimport added a subscriber: Unknown Object (MLST).

One thing I'm not sure is where these tests should be defined: if a gadget has internal name "foo", but is defined on pages with different names, such as "MediaWiki:gadget-bar.js" and "MediaWiki:gadget-bar.css", where would we define the QUnit tests which would be executed when accessing

  • [[Special:JavaScriptTest/qunit/foo]]
  • Special:JavaScriptTest/qunit?gadget=foo

Should it be...

  • ... in [[MediaWiki:Gadget-foo/QUnit.js]] ? (then it would not be very obvious for users that its code is related to [[MediaWiki:Gadget-bar.js]])
  • ... in [[MediaWiki:Gadget-bar/QUnit.js]] (or [[MediaWiki:Gadget-bar.js/QUnit.js]]) ? (this would mean there could be more than one page where the Unit tests of a single gadget are defined - as many as the number of parts of this gadget)

What do you think?

We can probably do this once the Gadgets 2.0 infrastructure is in place...making this depend upon that.

Copying what I wrote on T234661

Hi all. I've created w:en:User:Evad37/WikiUnit.js to make on-wiki unit testing of gadgets and scripts a bit easier to implement, and available when previewing or showing changes to code. Ideally this, or something like, it would become an extension. Feedback would be appreciated at https://en.wikipedia.org/wiki/Wikipedia:Interface_administrators%27_noticeboard#Gadget_and_userscript_unit_testing