Skip to content

Commit

Permalink
Build browser mocha for 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstjules committed Jan 26, 2016
1 parent aa25b1c commit a25ac95
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -5058,18 +5058,9 @@ Runner.prototype.uncaught = function(err) {
this.emit('end');
};

/**
* Cleans up the reference to the test's deferred function.
* @see cleanSuiteReferences for details.
* @param {Test} test
*/
function cleanTestReferences(test) {
delete test.fn;
}

/**
* Cleans up the references to all the deferred functions
* (before/after/beforeEach/afterEach) of a Suite.
* (before/after/beforeEach/afterEach) and tests of a Suite.
* These must be deleted otherwise a memory leak can happen,
* as those functions may reference variables from closures,
* thus those variables can never be garbage collected as long
Expand Down Expand Up @@ -5099,6 +5090,10 @@ function cleanSuiteReferences(suite) {
if (isArray(suite._afterEach)) {
cleanArrReferences(suite._afterEach);
}

for (var i = 0; i < suite.tests.length; i++) {
delete suite.tests[i].fn;
}
}

/**
Expand Down Expand Up @@ -5133,7 +5128,6 @@ Runner.prototype.run = function(fn) {
debug('start');

// references cleanup to avoid memory leaks
this.on('test end', cleanTestReferences);
this.on('suite end', cleanSuiteReferences);

// callback
Expand Down

0 comments on commit a25ac95

Please sign in to comment.