Search code examples
istanbulnyc

nyc equivalent of istanbul command


I am trying to convert my istanbul code coverage commands to nyc.

It appears as though nyc is now the command line interface for the istanbul test coverage library.

With istanbul, we'd get coverage like so:

istanbul cover foo.js --dir coverage

then we'd get a consolidated report like so:

istanbul report --dir coverage --include **/*coverage.json lcov

so I am trying to determine what the equivalent command is with nyc -

to get coverage with nyc, it looks like I can do this:

nyc node foo.js  # writes coverage data to .nyc_output

but when I look in .nyc_output, there are a bunch of .json files but they don't seem to have any data in them.

If I try to get a report, using

nyc report --reporter=lcov

That report command doesn't seem to do anything, the .nyc_output directory looks the same as before:

enter image description here

Note I am fine with using configuration files and avoiding extra commands at the command line.


Solution

  • Official documentation proposes using it like this:

    nyc --reporter=lcov npm test