I've tried to make zombie work with mocha, but unless I use the mocha --ignore-leaks command options, my test always fails with the error:
Error: global leaks detected: k, i, name, chars, char
My test looks exactly like the one explained in this thread: Mocha and ZombieJS
I wish I could have posted my question there, but as a newbie, I cannot comment on the thread, only ask a new question.
Do you have any idea why I get these leaks? I'm using mocha 1.0.3 and zombie 1.0.0.
Mocha does not run individual tests in parallel. That means if you hand Mocha a single, lonely test file, it will spawn a single worker process, and that worker process will run the file. If you only have one test file, you'll be penalized for using parallel mode. Don't do that.
Find out how you can ignore some tests in Mocha You can use the skip() method (on describe() or it() ) to ignore some tests: In case of describe , it will ignore all tests in the describe block (which includes all nested describe and it functions); In case of it , it will ignore the individual test.
The leaks can come either from your own code or from node_modules that you use. Mocha should give some hints on where the leaks are, such as forgetting to declare local variable with var.
// global leaks
a = 1;
// no leaks
var a = 1;
You might also be interested writing Node.js app in coffeescript since it helps you avoid mistakes like that. (It automatically initializes variables, using var) http://coffeescript.org/
There is a template that helps you get started here https://github.com/twilson63/express-coffee
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With