Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfill memory leak prevention. #328

Merged
merged 1 commit into from May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions addon-test-support/ember-qunit/index.js
Expand Up @@ -243,6 +243,21 @@ export function setupTestIsolationValidation() {
QUnit.done(reportIfTestNotIsolated);
}

// This polyfills the changes from https://github.com/qunitjs/qunit/pull/1279
// and should be removed when that change is released and included in a release
// version of QUnit
function polyfillMemoryLeakPrevention() {
QUnit.testDone(function() {
// release the test callback
QUnit.config.current.callback = undefined;
});

QUnit.moduleDone(function() {
// release the module hooks
QUnit.config.current.module.hooks = {};
});
}

/**
@method start
@param {Object} [options] Options to be used for enabling/disabling behaviors
Expand All @@ -260,6 +275,7 @@ export function setupTestIsolationValidation() {
of `Ember.onerror` will be disabled.
@param {Boolean} [options.setupTestIsolationValidation] If `false` test isolation validation
will be disabled.
@param {Boolean} [options._polyfillMemoryLeakPrevention] If `false` the polyfilled memory leak prevention will not be enabled.
*/
export function start(options = {}) {
if (options.loadTests !== false) {
Expand Down Expand Up @@ -289,6 +305,10 @@ export function start(options = {}) {
setupTestIsolationValidation();
}

if (options._polyfillMemoryLeakPrevention !== false) {
polyfillMemoryLeakPrevention();
}

if (options.startTests !== false) {
startTests();
}
Expand Down