Page 1 of 1

Report problems with JSCoverage-Server Proxy

Posted: 2011-02-16 3:45 am
by neunie
To Whom It May Concern:

I have a website that is heavily based on JavaScript and is now about three and half years old. It has gone through some drastic changes but I'm afraid we have not done a good job of pruning out old code.

I would like to begin pruning the JS and I believe that your tool would be very helpful.

We have JSUnit tests for a portion of the code but we also have a large suit of Selenium tests.

If I correctly understand how the JSCoverage-Server with the proxy option turned on works, I believe that I could enable the proxy and run my suit of Selenium tests. When finished look at the report to see what JS I could begin to prune.

I wanted to try this on my dev station. I'm running IIS and my site can be found http://localhost:11078.
Then cd to the JSCoverage dir and run: jscoverage-server --verbose --proxy
Change FireFox (tools > options > adv > settings > manual proxy... > 127.0.0.1:8080
Then load http://localhost:11078 into FF.
Click around the site then attempt to generate a coverage report by going to http://localhost:11078/jscoverage.html.

At this point I get a 404 error.

I feel like I'm simply missing a step but unsure of what that is.

I appreciate any help that you can give me.

Thanks,
Eric

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-16 5:06 pm
by Ed
neunie wrote: Change FireFox (tools > options > adv > settings > manual proxy... > 127.0.0.1:8080
Make sure you change the default "No Proxy for: localhost, 127.0.0.1".
neunie wrote: Then load http://localhost:11078 into FF.
If you're running jscoverage-server with the --verbose option, it should generate a lot of output at this point (one line for each HTTP request - including scripts, style sheets, images, etc.). Are you seeing this?

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-16 5:38 pm
by neunie
I'm afraid that I was not seeing anything display after in the console after I entered the line.

jscoverage-server --verbose --proxy

In regards to FF, I turned "No Proxy" off and "Manual Proxy" on. With 127.0.0.1 in the http field and 8080 in the Port field.

Thanks for your reply.

-eric

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-16 6:05 pm
by Ed
neunie wrote:In regards to FF, I turned "No Proxy" off and "Manual Proxy" on. With 127.0.0.1 in the http field and 8080 in the Port field.
What is in the "No Proxy for:" field? Is it blank?

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-17 12:21 am
by neunie
I finally got what you getting at.

The value was set to:

localhost, 127.0.0.1

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-18 3:57 am
by neunie
I spent some time working with it tonight and got a lot closer than I had the other night.

I set the "no proxy" field to 127.0.0.1:8080.

When I pull up my local website, I see statements like,

Code: Select all

GET http://localhost:39883/Home/About HTTP/1.1
GET http://localhost:39883/jscoverage.html HTTP/1.1
GET http://localhost:39883/jscoverage-highlight.css HTTP/1.1
GET http://localhost:39883/jscoverage.css HTTP/1.1
GET http://localhost:39883/jscoverage.js HTTP/1.1
GET http://localhost:39883/jscoverage-throbber.gif HTTP/1.1
In my server window.

I can now type in http://localhost:39883/jscoverage.html and get a report.

I just can't get it to list any .js files summary window.

Thanks for your help,
Eric

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-18 9:25 pm
by Ed
neunie wrote:I set the "no proxy" field to 127.0.0.1:8080.
There's no need for 127.0.0.1:8080 there - you should not need to connect to the proxy (i.e., 127.0.0.1:8080) directly. This can be left blank.
neunie wrote:I can now type in http://localhost:39883/jscoverage.html and get a report.

I just can't get it to list any .js files summary window.
When you just type in http://localhost:39883/jscoverage.html in your browser, you will load the jscoverage.html page, but at this point jscoverage.html has no coverage data. What you need to do is one of the following:
  1. Load jscoverage.html in your browser, then in the "Browser" tab, load a web page (the SUT - System Under Test) in the iframe.
  2. Load jscoverage.html in your browser, then in the "Browser" tab, open the SUT in a new window.
  3. Load the SUT in your browser first, and then use the SUT to open the jscoverage.html page in a new window. This option means you will need to modify your SUT page to open the new window. Typically this means adding a button like this:

    Code: Select all

    <button type="button" onclick="window.open('http://localhost:39883/jscoverage.html');">Coverage report</button>
    
When you do one of these things jscoverage.html will have access to coverage data from the SUT.

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-18 9:47 pm
by neunie
Ed,

It sounds like option#3 would work the best with my selenium tests. It would be easy to add hidden webpage with the button and a step press the button at the beginning of my test suite.

I appreciate your help and look forward to trying it out this weekend.

Thanks,
Eric

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-21 3:35 pm
by neunie
Ed,

Everything you suggested worked. The only problem I'm having now is that my selenium session does not appear to be using the proxy settings that I've set up in FF or Chrome. So now I'm just searching the web and trying to track down answers from others who have gotten this to work.

Thanks again for you help and what looks to be a great product.

-eric

Re: Report problems with JSCoverage-Server Proxy

Posted: 2011-02-22 4:29 am
by Ed
Are you using Selenium RC? Normally that will create its own Firefox profile instead of using the default profile. I think you can specify a profile to use with the -firefoxProfileTemplate option.