Javascript Code Coverage Tool for IE

I have a rather disgusting and large javascript file that I inherited from dev which I hate. There is a lot of dead code and I believe I wasted a lot of time refactoring functions that are not even called.

Ideally I just want something that can bind to the js engine and keep track of when and how many times the function is called.

In FF, I can get a list of functions by traversing the window object and dynamically wrapping them all in a method that will write a call to them and then call the function as usual.

Unfortunately in IE I cannot use this as I cannot find a way to get a list of all loaded functions. And I cannot run this application in FF as it is horribly different from the browser. Finally, there were 138 lines containing "new ActiveXObject (...)"

Help, with a tool that can do this, or at least a way to get a list of features that IE7 has loaded from a user script.

Thanks -c

+2


source to share


2 answers


Try JSCoverage .

Aoverage is a tool that code for JavaScript programs.

AOsilk by way of JavaScript code used in web pages. Code coverage statistics are collected and instrumented JavaScript is executed in a web browser.

The toolkit can be executed on the fly if you have set up the JSCoverage server to run as an HTTP proxy and configure your browser to go through it.

One way to use it:

  • Run AO trusted server in proxy mode:


jscoverage-server --proxy --verbose
  1. Configure your browser to use localhost: 8080 as your HTTP proxy.
  2. Add the following bookmarklet, making sure the relative path to jscoverage is correct:
javascript: void (window.open ('jscoverage / jscoverage.html'))
  1. Run your tests.
  2. Run the bookmarklet. A new window will appear showing the coverage results.
+4


source


There is a Firebug extension to cover JS code ...

FirebugCodeCoverage 0.1 ( https://addons.mozilla.org/en-US/firefox/addon/4837 )



Unfortunately it is not currently being updated for the latest version of FF.

0


source







All Articles