{"action":"opened","issue":{"url":"https://api.github.com/repos/gotwarlost/istanbul/issues/403","labels_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/403/labels{/name}","comments_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/403/comments","events_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/403/events","html_url":"https://github.com/gotwarlost/istanbul/issues/403","id":94523658,"number":403,"title":"Cannot report on multiple coverage.json files","user":{"login":"potatopankakes","id":4840608,"avatar_url":"https://avatars.githubusercontent.com/u/4840608?v=3","gravatar_id":"","url":"https://api.github.com/users/potatopankakes","html_url":"https://github.com/potatopankakes","followers_url":"https://api.github.com/users/potatopankakes/followers","following_url":"https://api.github.com/users/potatopankakes/following{/other_user}","gists_url":"https://api.github.com/users/potatopankakes/gists{/gist_id}","starred_url":"https://api.github.com/users/potatopankakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/potatopankakes/subscriptions","organizations_url":"https://api.github.com/users/potatopankakes/orgs","repos_url":"https://api.github.com/users/potatopankakes/repos","events_url":"https://api.github.com/users/potatopankakes/events{/privacy}","received_events_url":"https://api.github.com/users/potatopankakes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-12T01:46:44Z","updated_at":"2015-07-12T01:46:44Z","closed_at":null,"body":"I have two sub-directories with coverage outputs produced by `istanbul` in them.  One is from running functional tests, and the second is from unit tests.  I can use `istanbul` to report on them individually; however, reporting on them together (`istanbul report --include **/coverage.json`) fails.\r\n\r\nBelow shows the directory listing with 2 coverage sub-directories created from previous runs of `istanbul cover`:\r\n```bash\r\nLMDV-JEFFREYB:ns-api jburke$ ls\r\n./\t\t\t\tapplogs/\t\t\tnotes/\t\t\t\ttest/\r\n../\t\t\t\tcoverage-functionaltests/\tpackage.json\t\t\tx.istanbul.yml\r\nREADME.md\t\t\tcoverage-unittests/\t\tscripts/\t\t\txunit-functionaltests.xml*\r\napp.js\t\t\t\tnode_modules/\t\t\tsrc/\t\t\t\txunit-unittests.xml*\r\n```\r\nBelow shows a successful report run on the `coverage-functionaltests` sub-directory:\r\n```bash\r\nLMDV-JEFFREYB:ns-api jburke$ node_modules/.bin/istanbul report --root ./ --include coverage-functionaltests/coverage.json --dir ./coverage text-summary\r\n\r\n=============================== Coverage summary ===============================\r\nStatements   : 71.48% ( 218/305 )\r\nBranches     : 40% ( 36/90 )\r\nFunctions    : 65.48% ( 55/84 )\r\nLines        : 71.48% ( 218/305 )\r\n================================================================================\r\nDone\r\n```\r\nBelow shows a successful report run on the `coverage-unittests` sub-directory:\r\n```bash\r\nLMDV-JEFFREYB:ns-api jburke$ node_modules/.bin/istanbul report --root ./ --include coverage-unittests/coverage.json --dir ./coverage text-summary\r\n\r\n=============================== Coverage summary ===============================\r\nStatements   : 52.23% ( 434/831 )\r\nBranches     : 33.76% ( 133/394 )\r\nFunctions    : 40.11% ( 73/182 )\r\nLines        : 52.23% ( 434/831 )\r\n================================================================================\r\nDone\r\n```\r\nBelow shows the error when I glob them: \r\n```bash\r\nLMDV-JEFFREYB:ns-api jburke$ node_modules/.bin/istanbul report --root ./ --include **/coverage.json --dir ./coverage text-summary\r\n/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/reporter.js:58\r\n            throw inputError.create('Invalid report format [' + fmt + ']');\r\n                             ^\r\nError: Invalid report format [coverage-unittests/coverage.json]\r\n    at Object.module.exports.create (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/util/input-error.js:7:15)\r\n    at Object.Reporter.add (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/reporter.js:58:30)\r\n    at /Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/reporter.js:69:18\r\n    at Array.forEach (native)\r\n    at Object.Reporter.addAll (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/reporter.js:68:14)\r\n    at ReportCommand.Command.mix.run (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/command/report.js:101:18)\r\n    at runCommand (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/cli.js:78:19)\r\n    at runToCompletion (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/cli.js:82:5)\r\n    at Object.<anonymous> (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/cli.js:88:5)\r\n    at Module._compile (module.js:460:26)\r\n```\r\nEntering the following directly in node works correctly:\r\n```\r\nLMDV-JEFFREYB:ns-api jburke$ node\r\n> process.version\r\n'v0.12.2'\r\n> var fs = require('fs'), istanbul = require('istanbul')\r\nundefined\r\n> var reporter = new istanbul.Reporter(), collector = new istanbul.Collector()\r\nundefined\r\n> reporter.addAll(['lcov', 'html', 'cobertura'])\r\nundefined\r\n> collector.add(JSON.parse(fs.readFileSync('coverage-functionaltests/coverage.json', 'utf8')))\r\nundefined\r\n> collector.add(JSON.parse(fs.readFileSync('coverage-unittests/coverage.json', 'utf8')))\r\nundefined\r\n> reporter.write(collector, true, function () { console.log('done') })\r\n```\r\nThe above sequence produces a correct set of 'merged' output results in `./coverage/`.  \r\n\r\nIf I reverse the order of additions of the coverage.json files in the above example, the 2nd `add` fails.  I'm guessing that this is somehow related to what happens when running from the CLI.  Here is the failure on the 2nd add:\r\n```\r\n> collector2.add(JSON.parse(fs.readFileSync('coverage-unittests/coverage.json', 'utf8')))\r\nundefined\r\n> collector2.add(JSON.parse(fs.readFileSync('coverage-functionaltests/coverage.json', 'utf8')))\r\nTypeError: Cannot read property 'length' of undefined\r\n    at /Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/object-utils.js:247:37\r\n    at Array.forEach (native)\r\n    at Object.mergeFileCoverage (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/object-utils.js:244:31)\r\n    at /Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/collector.js:71:44\r\n    at Array.forEach (native)\r\n    at Object.Collector.add (/Users/jburke/Documents/Src/NS/ns-api/node_modules/istanbul/lib/collector.js:68:31)\r\n    at repl:1:12\r\n    at REPLServer.defaultEval (repl.js:132:27)\r\n    at bound (domain.js:254:14)\r\n    at REPLServer.runBound [as eval] (domain.js:267:12)\r\n```\r\n\r\nI can mail/post the input `coverage.json` files if needed.  \r\n\r\nVersion of `istanbul` is `0.3.17`, and I know it also happens with `0.3.15`\r\n\r\nRunning on Mac host:\r\n```bash\r\nLMDV-JEFFREYB:ns-api jburke$ uname -a\r\nDarwin LMDV-JEFFREYB 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64\r\n```"}}