2

I've already made setup for typescript+babel(stage-1+react) project with mocha tests + istanbul coverage. Mocha is configured this way: webpack builds commonjs bundles in tmp directory with istanbul-instrumenter-loader. Entry points are files that match ./**/*.spec.(t|j)sx?, jsx? loader looks like:

loaders: [
   'istanbul-instrumenter-loader',
   "source-map-loader",
   'babel-loader',
],

where source-map-loader is my module that just writes sourceMap, that is passed to the loader, to the [file base name].map(e.g. app.js.map) files for each bundle file. After the build is done I run gulp task for mocha which adds all this bundles to mocha runner, starts tests and after it collect coverage info.

Yesterday I've found remap-istanbul project and have tried to configure it. You can look at coverage report module with remap added here. It is always failes with this output:

/app/node_modules/istanbul/lib/store/memory.js:38
     throw new Error('Unable to find entry for [' + key + ']');
     ^

Error: Unable to find entry for [src/actions/appointments.js]
  at MemoryStore.Store.mix.get  (/app/node_modules/istanbul/lib/store/memory.js:38:19)
  at HtmlReport.Report.mix.writeDetailPage (/app/node_modules/istanbul/lib/report/html.js:411:67)
  at /app/node_modules/istanbul/lib/report/html.js:489:26
  at SyncFileWriter.extend.writeFile (/app/node_modules/istanbul/lib/util/file-writer.js:57:9)
  at FileWriter.extend.writeFile (/app/node_modules/istanbul/lib/util/file-writer.js:147:23)
  at /app/node_modules/istanbul/lib/report/html.js:488:24
  at Array.forEach (native)
  at HtmlReport.Report.mix.writeFiles (/app/node_modules/istanbul/lib/report/html.js:482:23)
  at /app/node_modules/istanbul/lib/report/html.js:484:22
  at Array.forEach (native)

I tried debugging test run and coverage collection, but couldn't figured out why it has broken file path, I guess it is because of webpack's sourcemap.

4

0 回答 0