Search code examples
node.jsunit-testingtest-coverage

Node.js test coverage


Could anyone, please, recommend simple test coverage tool for Node.js without using Mocha because I use simple functions from assert module of Node in my own test framework.


Solution

  • The standard library for code coverage is nyc, so that's my suggestion; however, you aren't going to get code coverage to work with a test framework you came up with yourself for free -- you'll need to make sure you are instrumenting the appropriate source files so the report contains what you expect.

    The following links, which discuss non-standard uses of nyc (non-standard meaning, not jasmine or mocha) might be useful - one for classic istanbul, one for the newer nyc: https://github.com/gotwarlost/istanbul/issues/574 https://github.com/istanbuljs/nyc/issues/548