From: Timo Tijhof Date: Wed, 3 Apr 2013 19:17:08 +0000 (+0200) Subject: Test: Assert that modules loaded correctly. X-Git-Tag: 1.31.0-rc.0~20110^2 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=efc1344feabbbc0a3fa7dd64fcd2143894786aec;p=lhc%2Fweb%2Fwiklou.git Test: Assert that modules loaded correctly. Since mw.loader catches any uncaught exceptions that modules throw at run time, it is hard for QUnit and/or the browser (e.g. PhantomJS) to know about a failure because there is no assert failure and no uncaught exception (window.onerror). VisualEditor's init module, for example, has a problem (bug 45175) that sometimes causes an error, causing none of the tests to run, yet the QUnit run would finish successful with simply none of the VE tests included in the results. Bug: 44299 Change-Id: Ib6e2b8d1be3e38fd9f1b948407c62da550fce0b4 --- diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index a6f729b2ea..3f3c8992ee 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -351,6 +351,25 @@ assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' ); } ); + QUnit.test( 'Loader status', 2, function ( assert ) { + var i, len, state, + modules = mw.loader.getModuleNames(), + error = [], + missing = []; + + for ( i = 0, len = modules.length; i < len; i++ ) { + state = mw.loader.getState( modules[i] ); + if ( state === 'error' ) { + error.push( modules[i] ); + } else if ( state === 'missing' ) { + missing.push( modules[i] ); + } + } + + assert.deepEqual( error, [], 'Modules in error state' ); + assert.deepEqual( missing, [], 'Modules in missing state' ); + } ); + QUnit.test( 'htmlEqual', 8, function ( assert ) { assert.htmlEqual( '

Child paragraph with A link

Regular textA span
',