no js files listed in the summary tab

Questions, problems, suggestions, bug reports, and so on.
Post Reply
odjs
Posts: 2
Joined: 2008-04-18 9:12 pm

no js files listed in the summary tab

Post by odjs »

Hello:

I have the same issue that no JS files are listed in the summary tab. View Page Source, i don't see /* automatically generated by JSCoverage - do not edit */.

I tried to copy all js files to the same location as jscoverage.htm file location.

For sure that my JS files are executed for our application which I want to test with.

Thanks for your help.
Jason
siliconforks
Site Admin
Posts: 34
Joined: 2007-05-26 5:25 am

Re: no js files listed in the summary tab

Post by siliconforks »

Hello Jason,

I should clarify that the "/* automatically generated by JSCoverage - do not edit */ " should be in the script files - jscoverage does not modify the HTML files. Are you viewing the source of the .html files or the .js files?
odjs
Posts: 2
Joined: 2008-04-18 9:12 pm

Re: no js files listed in the summary tab

Post by odjs »

Hello:

I saw the /* automatically generated by JSCoverage - do not edit */ when I open the generated js files after executed >jscoverage SOURCE_DIR DEST_DIR.

SOURCE_DIR = mydomain/path/jsfolder

DEST_DIR=mydomain/path where our application will start with.

I could open and run my application from our domain. i.e.: http://mydomain:1234/path/jscoverage.html?logon.jsp. Our application is launched and shows in your iframe. I login to our app and click around to execute our JS functions. Then I click the summary tab, there is not js files listed.

Executed js files for our application is a subfolder of our domain path, such as mydomain/path/jsfolder.

Not sure I miss any step.

Thanks.
Jason
siliconforks
Site Admin
Posts: 34
Joined: 2007-05-26 5:25 am

Re: no js files listed in the summary tab

Post by siliconforks »

odjs wrote:Hello:

I saw the /* automatically generated by JSCoverage - do not edit */ when I open the generated js files after executed >jscoverage SOURCE_DIR DEST_DIR.
Okay, so the instrumentation step is working ...

If you look at the script from within your browser, is the code instrumented? That is, if you access http://mydomain:1234/path/jsfolder/script.js in your browser, do you get the instrumented code? (An easier way to check for this is to use Firefox and Firebug and to use Firebug's "Script" tab. See http://siliconforks.com/doc/debugging-javascript/ for other alternatives.)
odjs wrote: SOURCE_DIR = mydomain/path/jsfolder

DEST_DIR=mydomain/path where our application will start with.
That doesn't sound quite right - generally you want to use the same path structure for the instrumented code as for the original code, so the instrumented code replaces the original code. For example, if the source code of your web application is arranged as described in http://tomcat.apache.org/tomcat-6.0-doc ... ource.html, you would run something like this:

Code: Select all

jscoverage web build
If you only want to instrument the code under a specific path within your web application, you would do something like this (after creating the build/ directory):

Code: Select all

jscoverage web/path build/path
Guest

Re: no js files listed in the summary tab

Post by Guest »

where should *jscoverage.js and *.jscoverage.html be located? our JS folder? or our domain folder, the same as our logon.jsp folder?

From user guide, the SOURCE_DIR is our JS files location for jscoverage to copy all existing js files and instrument them for js coverage to use.

our folder structure:

domain logon page: \\webapp\logon.jsp
js files: \\webapp\jsfolder\*.js

How do I do for SOURCE_DIR and DEST_DIR?

Should I do: jscoverage web build as jscoverage webapp webapp\jsfolder?

I only want to instrument the js code unser \\webapp\jsfolder. How do I run jscoverage and its parameters?

Thanks.
Jason
siliconforks
Site Admin
Posts: 34
Joined: 2007-05-26 5:25 am

Re: no js files listed in the summary tab

Post by siliconforks »

Guest wrote:where should *jscoverage.js and *.jscoverage.html be located? our JS folder? or our domain folder, the same as our logon.jsp folder?
The JS folder. For every JavaScript file x.js, you should see a file x.js.jscoverage.js (and x.js.jscoverage.html) in the same folder as x.js.
Guest wrote:From user guide, the SOURCE_DIR is our JS files location for jscoverage to copy all existing js files and instrument them for js coverage to use.

our folder structure:

domain logon page: \\webapp\logon.jsp
js files: \\webapp\jsfolder\*.js

How do I do for SOURCE_DIR and DEST_DIR?

Should I do: jscoverage web build as jscoverage webapp webapp\jsfolder?
No, you need to have a build folder (DEST_DIR) which is totally distinct from your source folder. The jscoverage program copies an entire folder, and all its subfolders, recursively, instrumenting any .js files. The destination folder should not be a subfolder of the source folder - if you did that, running "jscoverage webapp webapp\jsfolder", you would end up with something like this:

Code: Select all

webapp\logon.jsp
webapp\jsfolder\
webapp\jsfolder\script.js                                (original JavaScript code)
webapp\jsfolder\logon.jsp                                (!)
webapp\jsfolder\jsfolder\                                (this is surely not what you want)
webapp\jsfolder\jsfolder\script.js                       (instrumented JavaScript code)
webapp\jsfolder\jsfolder\script.js.jscoverage.js
(Actually I think this would not happen, because jscoverage would detect that the destination folder is contained inside the source folder and abort.)

You should be doing something like

Code: Select all

jscoverage webapp webapp2
Now webapp\ contains your original web application, untouched, while webapp2\ contains the instrumented version of your web application.
Guest wrote:I only want to instrument the js code unser \\webapp\jsfolder. How do I run jscoverage and its parameters?
First, before you run jscoverage, create the build folder (e.g., webapp2\). Then run

Code: Select all

jscoverage webapp\jsfolder webapp2\jsfolder
Then copy logon.jsp and any other files and/or subfolders (except jsfolder\) from webapp\ to webapp2\.

This will create the jscoverage.html file in webapp2\jsfolder. That should not cause problems, but it makes the URL to access your logon page slightly more complicated: it will look something like

Code: Select all

http://mydomain:1234/path/jsfolder/jscoverage.html?../logon.jsp
Guest

Re: no js files listed in the summary tab

Post by Guest »

Why we have to copy logon.jsp and other files and folders from "webapp" folder to "webapp2" folder? After that we have all apps structure in webapp2 and run our web application from webapp2 folder? That will not work since there are some security path are configured in web server to map to "webapp" folder.

Why I could not copy all instrumented *.jscoverage.js and *.jscoverage.html files to our original jsfolder and run url like this: http://mydomain:1234/webapp/jsfolder/js ... /logon.jsp? I tried it and does not work.

I tried to create "webapp2" folder as some level of our "webapp" folder and copy every over from webapp to webapp2. Then I could not use http://mydomain:1234/webapp2/jsfolder/jscoverage.html to test opening jscoverage page. Because webapp2 is not mapped as our web application folder.

our web folder structure is:

apps/webapp/logon.jsp and other files. subfolders
apps/webapp/1.0/jscripts/*.js

our url:
http://mydomain:1234/apps/logon.jsp
webapp is mapped as default folder.

if I create webapp2 as apps/webapp2. And run jscoverage webapp/1.0/jsfolder webapp2/1.0/jsfolder, instrumented js and html files are created.

Then I could not lunch webapp2/1.0/jsfolder/jscoverage.html from our domain because webapp2 is not our default folder.
Both URL like this does not work: http://mydomain:1234/apps/1.0/jsfolder/jscoverage.html or http://mydomain:1234/apps/webapp2/1.0/j ... erage.html

In order to access to instrumented jscoverage.html from our domain entry, the build dir (DEST_DIR) have to be under our "webapp" folder.

For example:
create folder: apps/webapp/jscoverage/1.0/jsfolder
Then run: jscoverage webapp/1.0/jsfolder webapp/jscoverage/1.0/jsfolder
Instrumented files are created.

The URL http://mydomain:1234/apps/jscoverage/1/ ... /logon.jsp could run our application. However, no JS files are shown in summary tab.
siliconforks
Site Admin
Posts: 34
Joined: 2007-05-26 5:25 am

Re: no js files listed in the summary tab

Post by siliconforks »

Guest wrote:Why we have to copy logon.jsp and other files and folders from "webapp" folder to "webapp2" folder? After that we have all apps structure in webapp2 and run our web application from webapp2 folder? That will not work since there are some security path are configured in web server to map to "webapp" folder.
The point is you must have separate source and deployment (also called build) folders. The jscoverage program replaces your JavaScript files with instrumented versions. If jscoverage worked by doing everything in one folder, it would clobber your original JS source files, and then they're gone forever!

If you need to have "webapp\" be your deployment folder, that's fine; but then you need a separate source folder, say, "src\", and run jscoverage like this:

Code: Select all

jscoverage src webapp
Or, if you wanted to instrument only files in "jsfolder\":

Code: Select all

jscoverage src\jsfolder webapp\jsfolder
Guest wrote:Why I could not copy all instrumented *.jscoverage.js and *.jscoverage.html files to our original jsfolder and run url like this: http://mydomain:1234/webapp/jsfolder/js ... /logon.jsp? I tried it and does not work.
That could work, but it's error-prone and I recommend against it - there are a lot of files you need to copy, and you need to be careful to preserve the exact folder and subfolder structure or things will break. You would need to copy all the following files:

Code: Select all

jsfolder\jscoverage.html
jsfolder\jscoverage.css
jsfolder\jscoverage.js
jsfolder\jscoverage-throbber.gif
jsfolder\jscoverage-sh_main.js
jsfolder\jscoverage-sh_javascript.js
jsfolder\jscoverage-sh_nedit.css
jsfolder\*.js.jscoverage.html
jsfolder\*.js.jscoverage.js
jsfolder\subfolder\*.js.jscoverage.html           (if you have any subfolders in jsfolder\)
jsfolder\subfolder\*.js.jscoverage.js
Also, this list of files may change in the next version of JSCoverage - do not count on it remaining the same from version to version.
Guest wrote: I tried to create "webapp2" folder as some level of our "webapp" folder and copy every over from webapp to webapp2. Then I could not use http://mydomain:1234/webapp2/jsfolder/jscoverage.html to test opening jscoverage page. Because webapp2 is not mapped as our web application folder.

our web folder structure is:

apps/webapp/logon.jsp and other files. subfolders
apps/webapp/1.0/jscripts/*.js

our url:
http://mydomain:1234/apps/logon.jsp
webapp is mapped as default folder.

if I create webapp2 as apps/webapp2. And run jscoverage webapp/1.0/jsfolder webapp2/1.0/jsfolder, instrumented js and html files are created.

Then I could not lunch webapp2/1.0/jsfolder/jscoverage.html from our domain because webapp2 is not our default folder.
Both URL like this does not work: http://mydomain:1234/apps/1.0/jsfolder/jscoverage.html or http://mydomain:1234/apps/webapp2/1.0/j ... erage.html

In order to access to instrumented jscoverage.html from our domain entry, the build dir (DEST_DIR) have to be under our "webapp" folder.

For example:
create folder: apps/webapp/jscoverage/1.0/jsfolder
Then run: jscoverage webapp/1.0/jsfolder webapp/jscoverage/1.0/jsfolder
Instrumented files are created.

The URL http://mydomain:1234/apps/jscoverage/1/ ... /logon.jsp could run our application. However, no JS files are shown in summary tab.
This is getting really complicated - as I noted above, if your web server has to run from "webapp\" and you can't change that, then I would create a separate source folder and use "webapp\" (or "webapp\jsfolder\") as your DEST_DIR.
Guest

Re: no js files listed in the summary tab

Post by Guest »

This is getting really complicated - as I noted above, if your web server has to run from "webapp\" and you can't change that, then I would create a separate source folder and use "webapp\" (or "webapp\jsfolder\") as your DEST_DIR.
Yes. I tried to create a sub folder as DEST_DIR as "apps\webapp\jscoverage\1.0\jsfolder". Then run jscoverage apps\webapp\1.0\jsfolder apps\webapp\jscoverage\1.0\jsfolder.
All files: jscoverage.*, *.jscoverage.js, and *.jscoverage.html are created.

our jsfolder is very simple. Only have some js files, no sub folder there.

Launch url:
http://mydomain:1234/apps/jscoverage/1. ... /logon.jsp

The application loaded and application itself is working fine within your iframe. However, after some testing and click the Summary tab, there is not js file loaded.
siliconforks
Site Admin
Posts: 34
Joined: 2007-05-26 5:25 am

Re: no js files listed in the summary tab

Post by siliconforks »

Guest wrote: Yes. I tried to create a sub folder as DEST_DIR as "apps\webapp\jscoverage\1.0\jsfolder". Then run jscoverage apps\webapp\1.0\jsfolder apps\webapp\jscoverage\1.0\jsfolder.
All files: jscoverage.*, *.jscoverage.js, and *.jscoverage.html are created.
But using a subfolder of your web server directory will not work, because it modifies the URLs of script files within your web application.
Guest wrote: our jsfolder is very simple. Only have some js files, no sub folder there.

Launch url:
http://mydomain:1234/apps/jscoverage/1. ... /logon.jsp

The application loaded and application itself is working fine within your iframe. However, after some testing and click the Summary tab, there is not js file loaded.
Here you are accessing the login page at

Code: Select all

http://mydomain:1234/apps/logon.jsp
(within the iframe). But this page refers to scripts in "1.0/jsfolder", not in "jscoverage/1.0/jsfolder". So you are using the original .js files instead of the instrumented .js files.

You MIGHT be able to get this to work IF your web application uses nothing but relative URLs: you can copy the file logon.jsp, and all the rest of the files and subfolders in your web application, to the folder "apps\webapp\jscoverage\". Then access the logon page with the URL

Code: Select all

http://mydomain:1234/apps/jscoverage/1.0/jsfolder/jscoverage.html?../../logon.jsp
(note that this uses ../../logon.jsp instead of ../../../logon.jsp)
But this will break things if your web application uses any absolute URLs (starting with "http://" or even just "/").
Guest

Re: no js files listed in the summary tab

Post by Guest »

I finally make it work for our application.

Great tool!

Thanks.
Jason
Post Reply