Skip to content

Instantly share code, notes, and snippets.

@sai-fe
Forked from alfonsodev/Makefile
Created December 30, 2016 14:14
Show Gist options
  • Save sai-fe/c7d188826b1250aaad2318abe428bd69 to your computer and use it in GitHub Desktop.
Save sai-fe/c7d188826b1250aaad2318abe428bd69 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