code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

No Coverage reported for WebWorkers

Open agilgur5 opened this issue 4 years ago • 0 comments

So I have a bit of a unique set-up in that my library is an integration for both webpack and browserify. I use istanbul-instrument-loader and babel-plugin-istanbul to instrument each, respectively. It seems like my worker is being instrumented and my test code instantiates the worker, but I get coverage for everything except the worker. The webworkify function I export also has no reported coverage.

You can view the code at agilgur5/physijs-webpack#cypress-coverage. It's pretty tiny, basically just webpack.js, browserify.js, and browserify-worker-stub.js, which are all ~5-10 LoC, and their two 5 LoC tests (everything in the physijs/ directory is for the most part just vendored and can mostly be ignored). Can install, test, and see coverage with:

npm install && npm test && npx nyc report

Notably, physi_worker.js isn't present in the coverage report, and browserify-worker-stub.js shows no coverage for the function it exports (which is called by webworkify), despite tests running the worker. As this is an integration library, it'd be ideal to know that physijs (the library it integrates) itself isn't broken due to the integration, so high code coverage of it would give some confidence that nothing has broken.

I'm not totally sure if this is happening because of an istanbul issue or a cypress issue. When I ran the worker as a fake worker (i.e. on the same thread) in jsdom with jsdom-worker, I did get coverage for it. So I wonder if the reason it's not showing up in cypress's coverage reports is because it's running in a real worker. (Can read https://github.com/agilgur5/physijs-webpack/issues/6 for more details on how I tried to get coverage to work with all sorts of different toolks, but it shouldn't be necessary to understand this issue)

agilgur5 avatar Nov 27 '19 04:11 agilgur5