From f25b1e60dbe02589cff8b12b6449a609ec8db480 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 3 May 2018 16:22:40 -0400 Subject: [PATCH] Core: Ensure test callbacks and module hooks are released. --- src/test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test.js b/src/test.js index cf60dc08d..097fd3911 100644 --- a/src/test.js +++ b/src/test.js @@ -254,6 +254,10 @@ Test.prototype = { finish: function() { config.current = this; + // Release the test callback to ensure that anything referenced has been + // released to be garbage collected. + this.callback = undefined; + if ( this.steps.length ) { const stepsList = this.steps.join( ", " ); this.pushFailure( "Expected assert.verifySteps() to be called before end of test " + @@ -342,6 +346,11 @@ Test.prototype = { config.current = undefined; function logSuiteEnd( module ) { + + // Reset `module.hooks` to ensure that anything referenced in these hooks + // has been released to be garbage collected. + module.hooks = {}; + emit( "suiteEnd", module.suiteReport.end( true ) ); runLoggingCallbacks( "moduleDone", { name: module.name, @@ -351,6 +360,7 @@ Test.prototype = { total: module.stats.all, runtime: now() - module.stats.started } ); + } },