qunit: Remove race condition in 'test.mediawiki.qunit.testrunner'
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 11 Apr 2014 18:40:52 +0000 (11:40 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 11 Apr 2014 18:40:52 +0000 (11:40 -0700)
Tests should be atomic because when re-running failed tests, they
run out of order (by design).

The thing being asserted here wasn't all that useful as that is
upstream behaviour we ought to be able to rely on.

Change-Id: I2f006e1cf05f5535e8220ca8ffc2da603745d184

tests/qunit/data/testrunner.js

index 7dff354..ab9aab1 100644 (file)
@@ -5,7 +5,6 @@
 
        var mwTestIgnore, mwTester,
                addons,
-               envExecCount,
                ELEMENT_NODE = 1,
                TEXT_NODE = 3;
 
         * Small test suite to confirm proper functionality of the utilities and
         * initializations defined above in this file.
         */
-       envExecCount = 0;
        QUnit.module( 'test.mediawiki.qunit.testrunner', QUnit.newMwEnvironment( {
                setup: function () {
-                       envExecCount += 1;
                        this.mwHtmlLive = mw.html;
                        mw.html = {
                                escape: function () {
-                                       return 'mocked-' + envExecCount;
+                                       return 'mocked';
                                }
                        };
                },
        } ) );
 
        QUnit.test( 'Setup', 3, function ( assert ) {
-               assert.equal( mw.html.escape( 'foo' ), 'mocked-1', 'extra setup() callback was ran.' );
+               assert.equal( mw.html.escape( 'foo' ), 'mocked', 'setup() callback was ran.' );
                assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object applied' );
                assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object applied' );
 
                mw.messages.set( 'testMsg', 'Bar.' );
        } );
 
-       QUnit.test( 'Teardown', 3, function ( assert ) {
-               assert.equal( mw.html.escape( 'foo' ), 'mocked-2', 'extra setup() callback was re-ran.' );
+       QUnit.test( 'Teardown', 2, function ( assert ) {
                assert.equal( mw.config.get( 'testVar' ), 'foo', 'config object restored and re-applied after test()' );
                assert.equal( mw.messages.get( 'testMsg' ), 'Foo.', 'messages object restored and re-applied after test()' );
        } );
        QUnit.module( 'test.mediawiki.qunit.testrunner-after', QUnit.newMwEnvironment() );
 
        QUnit.test( 'Teardown', 3, function ( assert ) {
-               assert.equal( mw.html.escape( '<' ), '&lt;', 'extra teardown() callback was ran.' );
+               assert.equal( mw.html.escape( '<' ), '&lt;', 'teardown() callback was ran.' );
                assert.equal( mw.config.get( 'testVar' ), null, 'config object restored to live in next module()' );
                assert.equal( mw.messages.get( 'testMsg' ), null, 'messages object restored to live in next module()' );
        } );