☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fix test fn's being deleted too early for browser reporter
Daniel St. Jules02062fa05be3
diff --git a/lib/runner.js b/lib/runner.jsindex 9bb53441..e4d935e8 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -725,18 +725,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@@ -766,6 +757,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;+ }}/**@@ -800,7 +795,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