diff --git a/spec/helpers/resetEnv.js b/spec/helpers/resetEnv.js index cf12a0a9..af90b4b4 100644 --- a/spec/helpers/resetEnv.js +++ b/spec/helpers/resetEnv.js @@ -1,4 +1,8 @@ beforeEach(function() { - // env is stateful. Ensure that it does not leak between tests. - jasmineUnderTest.currentEnv_ = null; + // env is stateful. Ensure that it, and its global error event listeners, + // do not leak between tests. + if (jasmineUnderTest.currentEnv_) { + jasmineUnderTest.currentEnv_.cleanup_(); + jasmineUnderTest.currentEnv_ = null; + } });