5

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.

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

1

Official documentation proposes using it like this:

nyc --reporter=lcov npm test
Jehy
  • 4,729
  • 1
  • 38
  • 55
  • so the coverage and report command are one and the same? But I need to get a consolidated report for multiple processes, not just one process. – Alexander Mills Dec 21 '17 at 20:55
  • why not make consolidated coverage in one step? – Jehy Dec 25 '17 at 10:12
  • because I need to consolidate the coverage for multiple processes not just one process - my use case is a little different - it's for a library not an application – Alexander Mills Dec 25 '17 at 20:26