From 02062fa05be3f56168af37a10454621fde7a0884 Mon Sep 17 00:00:00 2001 From: "Daniel St. Jules" Date: Mon, 25 Jan 2016 23:13:10 -0800 Subject: [PATCH] Fix test fn's being deleted too early for browser reporter --- lib/runner.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 9bb53441c1..e4d935e8c2 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