Skip to content

Instantly share code, notes, and snippets.

@alfonsodev
Created January 12, 2014 00:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alfonsodev/8378678 to your computer and use it in GitHub Desktop.
Save alfonsodev/8378678 to your computer and use it in GitHub Desktop.
example Makefile of a Node.js project to create code coverage reports mocha, instanbul, coveralls
#!/bin/bash
MOCHA=node_modules/.bin/mocha
ISTANBUL=node_modules/.bin/istanbul
COVERALLS=node_modules/coveralls/bin/coveralls.js
# test files must start with "test*.js"
TESTS=$(shell find test/ -name "test*.js" -not -path "*service/*")
SERVICETEST=$(shell find test/service/ -name "test*.js" )
test:
$(MOCHA) -R spec $(TESTS)
test-service:
$(MOCHA) -R spec $(SERVICETEST)
test-debug:
$(MOCHA) debug -R spec $(TESTS)
test-coverage:
# Remove libcov if exits
rm -rf lib-cov/
rm -rf html-report/
$(ISTANBUL) instrument lib/ -o lib-cov/
TODO_COV=1 ISTANBUL_REPORTERS=lcov,text-summary,html $(MOCHA) --reporter mocha-istanbul $(TESTS)
test-coveralls:
echo TRAVIS_JOB_ID $(TRAVIS_JOB_ID)
cat lcov.info | $(COVERALLS)
.PHONY: coverage clean test test-debug test-coverage test-coveralls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment