1
votes

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!

3
your command seems to be ok , but you could try this : make -f MakeFile test . Also i would put the .Phony line before the test target and check my makefile with the command cat -e -t -v MakeFile --> it shows tabs as ^I and line endings as $ . let me know if it still dosent work - AppleBee12
Thanks. make -f did it. I will look up the meaning of that argument. - Nick
@ Nick , the -f command just says that the name after it is a file .... that it!! - AppleBee12
@Nick This is old, but make expects a file called makefile or Makefile. The uppercase F in makeFile/MakeFile is what trips this error. Case matters! - Adam Terlson

3 Answers

5
votes

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

3
votes

Did you try tabs instead of spaces?

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

Greetings,

2
votes

I suspect this is caused by an improperly named makefile.

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