How do you handle measuring Code Coverage in JavaScript
- by Dancrumb
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?