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).
He7d3r created this task.May 30 2012, 8:42 PM

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.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 22 2015, 12:04 AM
He7d3r updated the task description. (Show Details)Jan 6 2016, 9:26 PM
He7d3r set Security to None.
He7d3r removed a subscriber: wikibugs-l-list.
Qgil removed a subscriber: Qgil.Jan 7 2016, 2:17 PM
Catrope removed a subscriber: Catrope.Jan 15 2016, 11:00 PM
Krinkle removed a subscriber: Krinkle.
Evad37 added a subscriber: Evad37.Dec 10 2019, 11:42 PM

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

Izno added a subscriber: Izno.Dec 13 2019, 4:55 AM