I have a recursive function that calls itself in setTimeout
and in addEventListener
. All is fine and dandy, but if I use an anonymous function in the callback, it does not get counted in the coverage report.
For example, this reports an anonymous function that is not covered:
addEventListener('event', () => myFunction(myParameter));
While this doesn't:
addEventListener('event', myFunction.bind(myParameter));
I understand why this is the case, but how can I avoid the coverage deficit without altering my code?
Is this even worth bothering or should I just go with bind()
?
Aucun commentaire:
Enregistrer un commentaire