How do you handle measuring Code Coverage in JavaScript
Posted
by
Dancrumb
on Programmers
See other posts from Programmers
or by Dancrumb
Published on 2012-06-27T20:34:58Z
Indexed on
2012/06/27
21:25 UTC
Read the original article
Hit count: 292
In order to measure Code Coverage for JavaScript unit tests, one needs to instrument the code, run the tests and then perform post-processing.
My concern is that, as a result, you are unit testing code that will never be run in production. Since JavaScript isn't compiled, what you test should be precisely what you execute.
So here's my question, how do you handle this? One thought I had was to run Unit Testing on the production code and use that for my pass fail. I would then create a shadow of my production code, with instrumentation and run my unit tests again; this would give me my code coverage stats.
Has anyone come across a method that is a little more graceful than this?
© Programmers or respective owner