Skip to content

Commit 02062fa

Browse files
committed
Fix test fn's being deleted too early for browser reporter
1 parent 8522755 commit 02062fa

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/runner.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -725,18 +725,9 @@ Runner.prototype.uncaught = function(err) {
725725
this.emit('end');
726726
};
727727

728-
/**
729-
* Cleans up the reference to the test's deferred function.
730-
* @see cleanSuiteReferences for details.
731-
* @param {Test} test
732-
*/
733-
function cleanTestReferences(test) {
734-
delete test.fn;
735-
}
736-
737728
/**
738729
* Cleans up the references to all the deferred functions
739-
* (before/after/beforeEach/afterEach) of a Suite.
730+
* (before/after/beforeEach/afterEach) and tests of a Suite.
740731
* These must be deleted otherwise a memory leak can happen,
741732
* as those functions may reference variables from closures,
742733
* thus those variables can never be garbage collected as long
@@ -766,6 +757,10 @@ function cleanSuiteReferences(suite) {
766757
if (isArray(suite._afterEach)) {
767758
cleanArrReferences(suite._afterEach);
768759
}
760+
761+
for (var i = 0; i < suite.tests.length; i++) {
762+
delete suite.tests[i].fn;
763+
}
769764
}
770765

771766
/**
@@ -800,7 +795,6 @@ Runner.prototype.run = function(fn) {
800795
debug('start');
801796

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

806800
// callback

0 commit comments

Comments
 (0)