Help:Using QUnit

Semantic MediaWiki functionality relies in some part on JavaScript and jQuery and with an increasingly diverse browser environment (mobile and desktop browsers) different scopes putting constraints on provided functionality therefore testing across different platforms and browsers becomes vital to ensure similar user experiences and behaviour.

Register unit tests
Hooks/ResourceLoaderTestModules is used to register available tests.(See also SemanticMediawiki.hooks.php and tests/qunit folder.

Ensuring a continuous integration for JavaScript and jQuery, MediaWiki provides a JavaScript unit testing environment with 1.19 using the QUnit testing suite. A how-to for SMW specific task has yet to be decided but general information can be found at SMW JavaScript Testing with QUnit.

Best practices
[a.7] http://qunitjs.com/cookbook/

[a.8] http://benalman.com/talks/unit-testing-qunit.html

Namespace
Try to avoid polluting the global $/window namespace [a.2, a.3, a.4] and instead use smw/srf.

[a.2] https://gist.github.com/hallettj/64478

[a.3] http://yuiblog.com/blog/2007/06/12/module-pattern/

[a.4] http://www.javascripttoolbox.com/bestpractices/#namespace

Module pattern

 * http://yuiblog.com/blog/2007/06/12/module-pattern/

Testing environment
If $wgEnableJavaScriptTest is enabled and tests have been successfully registered, those can be accessed via Special:JavaScriptTest/qunit. If you want to run only a specific module, you can add  (e.g.  )