Last active
April 28, 2016 13:01
-
-
Save pepoviola/fcfd016b2ef79a22a09a020f78ad0504 to your computer and use it in GitHub Desktop.
detecting global leaks mocha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Detecting which module is causing a global leak can be cumbersome and boring. But there is a nice little trick to find the little bastard. Add these lines at the very beginning of your tests: | |
Object.defineProperty(global, "name_of_leaking_property", { | |
set : function(value) { | |
throw new Error("Found the leak!"); | |
} | |
}) | |
// This will print a stacktrace that shows which module caused the leak. | |
// https://github.com/mochajs/mocha/wiki/Detecting-global-leaks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment