gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

can't cover with mocha when using mock-fs #692

Closed fiws closed 8 years ago

fiws commented 8 years ago

Hi I am using this command istanbul cover _mocha -- -u exports -R spec test/**/*.js

and getting this error:

 "stack": [
   "Error: ENOENT, no such file or directory '/home/fiws/npm/lib/node_modules/istanbul/lib/assets'",
   "    at Binding.<anonymous> (/home/fiws/project/node_modules/mock-fs/lib/binding.js:604:13)",
   "    at maybeCallback (/home/fiws/project/node_modules/mock-fs/lib/binding.js:43:17)",
   "    at Binding.readdir (/home/fiws/project/node_modules/mock-fs/lib/binding.js:596:10)",
   "    at Object.fs.readdirSync (/home/fiws/project/node_modules/mock-fs/node/fs-6.3.0.js:909:18)",
   "    at Object.readdirSync (/home/fiws/project/node_modules/mock-fs/lib/index.js:59:31)",
   "    at copyAssets (/home/fiws/npm/lib/node_modules/istanbul/lib/report/html.js:543:20)",
   "    at /home/fiws/npm/lib/node_modules/istanbul/lib/report/html.js:562:13",
   "    at Array.forEach (native)",
   "    at HtmlReport.writeReport (/home/fiws/npm/lib/node_modules/istanbul/lib/report/html.js:561:26)",
   "    at LcovReport.writeReport (/home/fiws/npm/lib/node_modules/istanbul/lib/report/lcov.js:55:19)",
   "    at /home/fiws/npm/lib/node_modules/istanbul/lib/reporter.js:93:20",
   "    at Array.forEach (native)",
   "    at Object.write (/home/fiws/npm/lib/node_modules/istanbul/lib/reporter.js:87:30)",
   "    at process.<anonymous> (/home/fiws/npm/lib/node_modules/istanbul/lib/command/common/run-with-cover.js:249:30)",
   "    at process.g (events.js:286:16)",
   "    at emitOne (events.js:96:13)",
   "    at process.emit (events.js:188:7)",
   "    at process.exit (internal/process.js:146:15)",
   "    at done (/home/fiws/npm/lib/node_modules/mocha/bin/_mocha:416:32)",
   "    at afterWrite (_stream_writable.js:361:3)",
   "    at _combinedTickCallback (internal/process/next_tick.js:80:20)",
   "    at process._tickCallback (internal/process/next_tick.js:98:9)"
 ],
 "level": "error",
 "message": "uncaughtException: ENOENT, no such file or directory '/home/fiws/npm/lib/node_modules/istanbul/lib/assets'",
 "timestamp": "2016-08-30T07:51:25.280Z"

and the process hangs. Seems to be related to mock-fs used by the tests..

fiws commented 8 years ago

probably project related.

simeg commented 7 years ago

Are you calling mock.restore() in the tear down method? See the first example in the mock-fs README and this issue.