Skip to content

Commit 5a49381

Browse files
committed
qunit: Remove redundant conditional for sandbox teardown
Follows-up 0a20891, which added support for the `executeNow` parameter to QUnit.module. To properly support nested modules, we also need to skip registering a second setup and teardown because nested modules already run the beforeEach (setup), and afterEach (teardown), of their parent modules. During setup this would needlessly create two sandboxes and override the 'sandbox' property on the same 'this' context object. During teardown it would fail because the inner module's teardown would have already torn down the sandbox. Change-Id: Ib17bbbef45b2bd0247979cf0fa8aed17800c54a0
1 parent 8338cc0 commit 5a49381

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/qunit/data/testrunner.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
var orgModule = QUnit.module;
6565

6666
QUnit.module = function ( name, localEnv, executeNow ) {
67+
if ( QUnit.config.moduleStack.length ) {
68+
// When inside a nested module, don't add our Sinon
69+
// setup/teardown a second time.
70+
return orgModule.apply( this, arguments );
71+
}
72+
6773
if ( arguments.length === 2 && typeof localEnv === 'function' ) {
6874
executeNow = localEnv;
6975
localEnv = undefined;
@@ -85,9 +91,7 @@
8591
localEnv.teardown.call( this );
8692
}
8793

88-
if ( this.sandbox ) {
89-
this.sandbox.verifyAndRestore();
90-
}
94+
this.sandbox.verifyAndRestore();
9195
}
9296
}, executeNow );
9397
};

0 commit comments

Comments
 (0)