node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Removing records for some files from lcov file


Build status dependencies devdependencies


npm install lcov-filter --save-dev
node node_modules/lcov-filter/index.js <> <filenames to exclude>

-- filename to exclude is used as RegExp

Filtered result is printed to STDOUT and can be piped to other tools, for example to send to


Pipe file cover/ and remove info for files that contain word test in the path, the output is then piped through coveralls module

node node_modules/lcov-filter/index.js cover/ test | ./node_modules/coveralls/bin/coveralls.js

It is better to use from a script command inside package.json, for example to send filtered data the the service

  "coveralls": "lcov-filter cover/ test | ./node_modules/coveralls/bin/coveralls.js",


I love testing and code coverage, and send coverage results to, which gives me nice badges. The problem is that sending combined code coverage for the soure code AND unit test code skews the average number upwards:

For example:

  • actual code is covered at 80%
  • unit test is covered at 100%
  • coveralls badge shows respectable, but misleading 90% code coverage

I am using lcov-filter to filter out test files from the code coverage before sending to generating more meaningful numbers. qunit-promises is one example that now reports only code coverage without adding tests.

Small print

Author: Gleb Bahmutov © 2014

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github