This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 787
/* istanbul ignore next */ still damages/changes Function.toString() output #856
Comments
The (TEMPORARY) fix in my own codebase uses run-time detection of istanbul, i.e. a function which checks if my code is executing in an istanbul/nyc environment. Now the tests PASS in both normal
while this additional unit test for the istanbul detector helper has been added to make sure the detector itself isn't buggy:
while the istanbul detector code looks like this:
which was derived from the Hope this helps someone out there while this issue is pending/open for istanbul... |
GerHobbelt
added a commit
to GerHobbelt/jison
that referenced
this issue
Dec 25, 2017
… provide unit tests to ensure both the istanbul run-time detector helper (`detectIstanbulGlobal()`) and the function source code stringifier/extractor helpers are on their best behaviour. Also fix the function code extractor to cope with the arrow function format `x => expression`.
GerHobbelt
added a commit
to GerHobbelt/jison
that referenced
this issue
Dec 25, 2017
…anbul` environment. This also takes care of gotwarlost/istanbul#856 until it's fixed in the mainline there. - fix: when both JSON5 and JISON input modes barf a hairball, assume the most important error is the JISON one (show that one first!), while it MAY be a JSON5 format error that triggered it (show that one last!). Also check for common JISON errors which are obviously never triggered by any odd JSON5 input format error: when we encounter such an error here, we don't confuse matters and forget about the JSON5 fail as it's irrelevant.
I confirm I have this bug, thanks for the workaround. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
One can use
/* istanbul ignore next */
to preventistanbul
/nyc
from instrumenting the next JS statement/expression, which works well, except when used on a function which will be processed by.toString(f)
via, for example,String(f)
to obtain the function source code in string format.Then it turns out the not-instrumented function source code was rewritten after all via some whitespace minification process, resulting in, for example, unit tests checking such
String(f)
output, FAILING when you run them in a istanbul/nyc environment.Example: https://github.com/GerHobbelt/jison/blob/master/packages/helpers-lib/tests/tests.js
These assertions all PASS when run in
node
/mocha
:while the same tests' code FAILS when executed in
nyc
+mocha
with this error report:which shows the whitespace minification of the functions-under-test by istanbul at work.
(Side note: here's the source code for the executed stringification helper
printFunctionSourceCode()
:AFAICT, this issue is closely related to #310, #674 with related discussion in puppeteer/puppeteer#1054
The text was updated successfully, but these errors were encountered: