Skip to content

Instantly share code, notes, and snippets.

@pepoviola
Last active April 28, 2016 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepoviola/fcfd016b2ef79a22a09a020f78ad0504 to your computer and use it in GitHub Desktop.
Save pepoviola/fcfd016b2ef79a22a09a020f78ad0504 to your computer and use it in GitHub Desktop.
detecting global leaks mocha
//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