Skip to content

Instantly share code, notes, and snippets.

@fiveisprime
Last active January 1, 2016 23:09
Show Gist options
  • Save fiveisprime/8214397 to your computer and use it in GitHub Desktop.
Save fiveisprime/8214397 to your computer and use it in GitHub Desktop.
Makefile with lint (JSHint), test (mocha), and coverage. Uses locally install modules - make sure that jshint, mocha, and istanbul are devDependencies.
SRC = $(wildcard *.js)
test: $(SRC)
@node_modules/.bin/jshint $^
@node_modules/.bin/istanbul test node_modules/.bin/_mocha \
-R spec -- \
--require should \
--reporter spec
# Uncomment if your tests are in a directory named test.
# .PHONY: test
@fiveisprime
Copy link
Author

In package.json:

"scripts": { "test": "make test" }

Run npm test to run tests, npm test --coverage to generate the coverage report.

@morenoh149
Copy link

could you help me out with my makefile? https://github.com/keystonejs/keystone/blob/testing-overhaul/Makefile @fiveisprime When I run make test it tries to run jshint then mocha. But if there are any jshint errors mocha never runs. Also when I just run make lint make complains about error 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment