-
Notifications
You must be signed in to change notification settings - Fork 786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
istanbul instrumentation function.toString() #310
Comments
ignore is just reporting fakery now. Doesn't mean "do not instrument". Need to look into this |
Have the same problem. I send function to MongoDB like: function filter(){
...
}
User.find({
$where: filter.toString()
}, function( error, users ){
// MongoError: ReferenceError: __cov_G1RH9TezwmrgBKIjkjZ4FQ is not defined
}); Do you know any way to avoid this? |
+1 met the same issue. 'function (){__cov_gjt0lukdoxUzQSDPHovUcQ.f[\'66\']++;__cov_gjt0lukdoxUzQSDPHovUcQ.s[\'219\']++;return document.title;}' but there is no
|
My solution: fnstr = fnstr.replace(/__cov_(.+?)\+\+;?/g, '') |
Brilliant!! I was having the same problem, and this is a beautiful solution. I made one addition...
I changed the ? to [,?]. This is because my .toString() result included an if statement with multiple items Istanbul generated:
Notice the Original regex resulted in With the modification the result is clean, running code. Thanks @fritx ! |
Another workaround is to have 2 same functions: first with export function fn () { ... }
// istanbul ignore next
function fnCopy () { ... }
... fnCopy.toString() ...
But this workaround is ugly and I don't like it. |
any downstream interpretation of function.toString(), as instrumented by istanbul, sees instrumentation code, interprets as garbage, and throws a ReferenceError. An example of this is eval'ing functions into different threads.
/* istanbul ignore next */ should cause the next 'thing' not to be instrumented
The text was updated successfully, but these errors were encountered: