browserify compiled our test.js file, then testling ran our code in a
local headless browser (we also could have used node), and then coverify
parsed the test output for code coverage data and printed some nicely formatted
results on stderr. Hooray!

and the exit code is non-zero because the coverage wasn't 100%:

$ echo $?
1

If you want to run code coverage for browser tests, you can use the
testling command:

$ browserify -t coverify example/test.js | testling | coverify

and the output and exit codes work exactly the same, except the code is running
in a browser instead of node.

methods

var coverify =require('coverify')

var parse =require('coverify/parse')

Usually you can just do browserify -t coverify to get code coverage but you
can also use the api directly if you want to use this code directly.

var stream = coverify(file, opts={})

Return a transform stream for file that will instrument the input source file
using console.log().

To use a different function from console.log(), pass in opts.output.

var stream = parse(cb)

Return a transform stream that accepts test output as input and looks for lines
starting with COVERAGE and COVERED to generate a coverage report in
cb(err, coverage, counts).

coverage is an object that maps filenames from the bundle files to arrays of
coverage data.

counts is an object mapping filenames to objects with expr and total
fields for how many expressions were covered and how many expressions were
present.

All of the non-/^(COVERAGE|COVERED)\s/ lines are passed through from the input
to the output.

Here is some example coverage data that you can generate with coverify --json: