Skip to content

Commit

Permalink
Core: Ensure test callbacks and module hooks are released.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed May 3, 2018
1 parent e3f0083 commit ec8f8e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test.js
Expand Up @@ -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 " +
Expand Down Expand Up @@ -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,
Expand All @@ -351,6 +360,7 @@ Test.prototype = {
total: module.stats.all,
runtime: now() - module.stats.started
} );

}
},

Expand Down

0 comments on commit ec8f8e7

Please sign in to comment.