Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make test doesn't do anything for mocha tests

Tags:

makefile

I'm following this example: http://brianstoner.com/blog/testing-in-nodejs-with-mocha/

I defined a Makefile in my root directory:

REPORTER = dot

test:
  @NODE_ENV=test ./node_modules/.bin/mocha \
    --reporter $(REPORTER) \

test-w:
  @NODE_ENV=test ./node_modules/.bin/mocha \
    --reporter $(REPORTER) \
    --watch

.PHONY: test test-w

But when I run 'make test' it says "make: Nothing to be done for `test'."

like image 247
chovy Avatar asked Nov 10 '12 08:11

chovy


People also ask

How do I run a mocha test from a module?

The gist is to wrap each Mocha test specification file in a function assigned to module.exports and then require each of these files in a master “test-runner” file that Mocha executes rather than the test files themselves. In the test-runner, you execute the require functions AFTER you have executed the setup-code.

Can Mocha run test-runner tests?

Mocha by default tries to execute all javascript files in the root test directory. However, you can point Mocha specifically to test-runner.js:

What is Mocha?

What is Mocha? It's just a coffee drink? No, in this context Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases, you can see more here.

How do I create a Mocha-Chai-test?

First, let's create a project called mocha-chai-tests. Install chai and mocha. Inside the project mocha-chai-tests, create a folder called tests and a file called calc.js. Now, we can create our first test. To do this, we'll create a describe () indicating that we're doing tests on a calculator and another one indicating the addition operation.


1 Answers

Turns out Makefiles are tab-sensitive -- and those were clobbered when I cut-n-paste the file...

In vi, i turned on tabs and spacing to fix it:

vi Makefile
:set list

Now you can retab the file and ensure you are doing it correctly.

like image 125
chovy Avatar answered Sep 18 '22 15:09

chovy