istanbuljs/istanbuljs

Code added by coverage reporting breaks tests that call .toString() on a function

traverse opened this issue · 0 comments

Hello, I'm running into some issues trying to generate a coverage report with Jest/Istanbul.

The issue I'm running into is with code that calls .toString() on a function. When running Jest with coverage some code gets added to record the coverage and that breaks the .toString() output. I believe that code is added by Istanbul. If that isn't the case let me know and I'll close this issue and open one with Jest instead.

You can find a reproduction in this sandbox https://codesandbox.io/p/sandbox/beautiful-noyce-vqqv0s?file=%2Fsrc%2Findex.ts.

This is probably not a very common use case since I didn't really find anything in the existing issues.

Edit: Didn't really add a question the first time around so here goes. Is there a way I can solve this issue easily or maybe work around it?