Skip to content

Commit

Permalink
Merge pull request #261 from emberjs/clear-module-0-4-x
Browse files Browse the repository at this point in the history
Reset `module` variable after all tests in module are completed.
  • Loading branch information
rwjblue authored Apr 6, 2017
2 parents f1e80f7 + fd38ea4 commit 2b21471
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ember-qunit/qunit-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ export function createModule(Constructor, name, description, callbacks) {
var beforeEach = beforeEachCallback(callbacks || description);
var afterEach = afterEachCallback(callbacks || description);

var module = new Constructor(name, description, callbacks);
var module;

qunitModule(module.name, {
qunitModule(name, {
setup: function(assert) {
var done = assert.async();

// storing this in closure scope to avoid exposing these
// private internals to the test context
module = new Constructor(name, description, callbacks);

// provide the test context to the underlying module
module.setContext(this);

Expand All @@ -67,7 +71,12 @@ export function createModule(Constructor, name, description, callbacks) {
}

var done = assert.async();
return Ember.RSVP.resolve(result).then(() => module.teardown()['finally'](done));
return Ember.RSVP.resolve(result)
.then(() => module.teardown())
.finally(() => {
module = null;
done();
});
}
});
}

0 comments on commit 2b21471

Please sign in to comment.