Merge "qunit: Test `before` and `after` hooks in QUnit testrunner"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 2 Feb 2018 01:27:33 +0000 (01:27 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 2 Feb 2018 01:27:34 +0000 (01:27 +0000)
tests/qunit/data/testrunner.js

index eef6703..06c146c 100644 (file)
                } );
        } );
 
+       QUnit.module( 'testrunner-hooks-outer', function () {
+               var beforeHookWasExecuted = false,
+                       afterHookWasExecuted = false;
+               QUnit.module( 'testrunner-hooks', {
+                       before: function () {
+                               beforeHookWasExecuted = true;
+
+                               // This way we can be sure that module `testrunner-hook-after` will always
+                               // be executed after module `testrunner-hooks`
+                               QUnit.module( 'testrunner-hooks-after' );
+                               QUnit.test(
+                                       '`after` hook for module `testrunner-hooks` was executed',
+                                       function ( assert ) {
+                                               assert.ok( afterHookWasExecuted );
+                                       }
+                               );
+                       },
+                       after: function () {
+                               afterHookWasExecuted = true;
+                       }
+               } );
+
+               QUnit.test( '`before` hook was executed', function ( assert ) {
+                       assert.ok( beforeHookWasExecuted );
+               } );
+       } );
+
 }( jQuery, mediaWiki, QUnit ) );