MakeFile to run Mocha tests with NPM

I am trying to create a MakeFile to run my Mocha unit tests with NPM. So I have Mocha installed and a unit test created in:

{project_root}/test/test.js

Now, when I try 'make test' Make replies with:

make: Nothing to be done for `test'.

Here's my MakeFile:

test:
    @./node_modules/.bin/mocha -u tdd
.PHONY: test

So real basic. I've read that Mocha will run all tests in the 'test' dir automatically. Is my MakeFile syntax incorrect?

Thanks!

Sorry I can't help with make syntax, but could I suggest instead to just create a test alias in your package.json so that you can run your tests with npm test. Here's a nice example: https://github.com/sequelize/sequelize/blob/master/package.json

Did you try tabs instead of spaces?

test:
  @NODE_ENV=test ./node_modules/.bin/mocha
.PHONY: test

Greetings,

I suspect this is caused by an improperly named makefile.

Rename your makefile to makefile or Makefile and do not use a capital F.

Heads up to anyone trying to get Mocha to work with coffee-script. You may need to change your --require line as well:

REPORTER = dot

test:
        @NODE_ENV=test ./node_modules/.bin/mocha \
            --compilers coffee:coffee-script \
            --require 'coffee-script/register' \
            --reporter $(REPORTER) \
            test/*.coffee

.PHONY: test