From efc1344feabbbc0a3fa7dd64fcd2143894786aec Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 3 Apr 2013 21:17:08 +0200 Subject: [PATCH] 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 --- tests/qunit/data/testrunner.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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
', -- 2.20.1