Open andrew-aladev opened 4 years ago
let useIstanbul = true; // Set this flag to enable or disable Istanbul
export function inlineWorker() { // Your inline worker code here if (useIstanbul) { // Instrumentation for Istanbul coverage cov_${id}++; } }
function inlineWorkerCopy() { // Your copy of the inline worker code without Istanbul instrumentation }
const data = (${useIstanbul ? inlineWorker : inlineWorkerCopy}) ...
;
const worker = new Worker(URL.createObjectURL(new Blob([data])));
Hello, we are working with web workers:
Istanbul is poisoning
inlineWorker
withcov_${id}++;
and worker fails. So we have to addistanbul ignore
But it means thatinlineWorker
will be uncovered. So we are using workaround: function copy.This workaround is ugly but works fine.
We can see here that
istanbul ignore
comments are not enough for everyday usage. Please add switch to disable istanbul in runtime. It may beinlineWorker.toString({ istanbul: false })
orinlineWorker_without_istanbul.toString()
, etc. Thank you.310 may be related.