This is a really quick tip. I was looking around on the internet for a way to pass Node arguments when calling Mocha binary. And I couldn’t find anything useful. Then I tried the following and it worked:
$ test node --expose-gc ./node_modules/.bin/mocha [...]
--expose-gc argument is just an example. You can pass any argument accepted by Node program.
In my specific case, I was trying to load dotenv config. In the end, the project’s MakeFile looked like:
test: @NODE_ENV=test node -r dotenv/config ./node_modules/.bin/mocha \ --require should \ --reporter spec \ --harmony \ --bail \ tests .PHONY: test
Photo credit: Matt Benson