JTD says "Object not defined", but it is defined, in another file that should be loaded

85 views
Skip to first unread message

David Karr

unread,
May 8, 2013, 9:24:55 PM5/8/13
to js-test...@googlegroups.com
Java 6, Maven 3.0.5, jsTestDriver Maven plugin 1.3.5.1.

I'm trying to use jsTestDriver for the first time.  I got through some minor obstacles with the jsTestDriver Maven plugin, and now I appear to be hitting a problem with jsTestDriver itself.

I have a small app that currently works fine.  I ran JSLint on it, and got nothing but WARNING lines.

The following is my "jsTestDriver.conf" file:

server: http://localhost:9876

load:
 - src/main/webapp/js/*.js
 - src/main/webapp/js/libs/*.js
 - src/main/webapp/js/profiling/*.js
 - src/main/webapp/js/mylibs/*.js

test:
 - src/test/webapp/js/*.js


The following is an excerpt from the log:
Running: java -classpath C:\somepath\.m2\repository\com\googlecode\jstd-maven-plugin\jstd-maven-plugin\1.3.5.1\jstd-maven-plugin-1.3.5.1.jar;C:\somepath\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\somepath\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\somepath\.m2\repository\com\google\jstestdriver\jstestdriver\1.3.5\jstestdriver-1.3.5.jar;C:\somepath\.m2\repository\org\codehaus\plexus\plexus-component-annotations\1.5.5\plexus-component-annotations-1.5.5.jar;C:\somepath\.m2\repository\org\sonatype\sisu\sisu-inject-bean\2.3.0\sisu-inject-bean-2.3.0.jar;C:\somepath\.m2\repository\org\sonatype\sisu\sisu-guice\3.1.0\sisu-guice-3.1.0-no_aop.jar;C:\somepath\.m2\repository\org\sonatype\sisu\sisu-guava\0.9.9\sisu-guava-0.9.9.jar;C:\somepath\.m2\repository\org\codehaus\plexus\plexus-utils\2.0.6\plexus-utils-2.0.6.jar;C:\somepath\.m2\repository\org\codehaus\plexus\plexus-interpolation\1.1\plexus-interpolation-1.1.jar;C:\somepath\.m2\repository\org\apache\xbean\xbean-reflect\3.4\xbean-reflect-3.4.jar;C:\somepath\.m2\repository\log4j\log4j\1.2.12\log4j-1.2.12.jar;C:\somepath\.m2\repository\commons-logging\commons-logging-api\1.1\commons-logging-api-1.1.jar;C:\somepath\.m2\repository\com\google\code\google-collections\google-collect\snapshot-20080530\google-collect-snapshot-20080530.jar;C:\somepath\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar;C:\somepath\.m2\repository\org\codehaus\woodstox\wstx-asl\3.2.6\wstx-asl-3.2.6.jar;C:\somepath\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\somepath\.m2\repository\org\sonatype\spice\model-builder\1.3\model-builder-1.3.jar;C:\somepath\.m2\repository\org\apache\maven\maven-project-builder\3.0-alpha-2\maven-project-builder-3.0-alpha-2.jar -jar C:\somepath\.m2\repository\com\google\jstestdriver\jstestdriver\1.3.5\jstestdriver-1.3.5.jar --basePath C:\somepath\workspace6\SunlightGUI --browser C:/Users/dk068x/AppData/Local/Google/Chrome/Application/chrome.exe --captureConsole --config C:\somepath\workspace6\SunlightGUI\src\test\resources\jsTestDriver.conf --port 9876 --runnerMode QUIET --tests all --verbose
setting runnermode QUIET
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/dd_belatedpng.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.4.2.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.4.2.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.6.4.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.6.4.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.address-1.3.1.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.address-1.3.1.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.browser.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.coo.kie.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.phpdate.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jstz.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/modernizr-1.6.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/underscore.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/mylibs/config.js
[ERROR] error loading file: /test/src/main/webapp/js/mylibs/controller.daily.js:1: Uncaught ReferenceError: Controller is not defined

This is the top of "controller.daily.js":
Controller.Daily = {
    _isInitialized: false,    

This is the top of "mylibs/controller.js" (note that it's covered by the "*.js" in the conf file), which defines the "Controller" object:
var Controller = {
   

Remember that the app is working fine, so there aren't any syntax errors, at least none that the code is hitting.

I tried changing the "conf" file to manually specify the "mylibs/controller.js" before the load of "mylibs/*.js", but that had no effect.

Cory Smith

unread,
May 9, 2013, 9:09:45 AM5/9/13
to JsTestDriver
From the look of it, mylibs/controller.js is never loaded. What does the revised conf look like?



--
You received this message because you are subscribed to the Google Groups "JsTestDriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to js-test-drive...@googlegroups.com.
To post to this group, send email to js-test...@googlegroups.com.
Visit this group at http://groups.google.com/group/js-test-driver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Karr

unread,
May 9, 2013, 10:10:32 AM5/9/13
to js-test...@googlegroups.com


On Thursday, May 9, 2013 6:09:45 AM UTC-7, Cory Smith wrote:
From the look of it, mylibs/controller.js is never loaded. What does the revised conf look like?

You mean the change that had no effect?  Here it is, if it matters:
server: http://localhost:9876

load:
 - src/main/webapp/js/*.js
 - src/main/webapp/js/libs/*.js
 - src/main/webapp/js/mylibs/controller.js

Nathan Redding

unread,
May 9, 2013, 10:34:25 AM5/9/13
to js-test...@googlegroups.com
I've been trying to recreate the issue by having a file named controller.daily.js depend on a file named controller.js. With default alphabetical wildcard loading, I get the same error, but when I add the controller.js explicitly before the wildcard, the problem goes away for me.

David Karr

unread,
May 9, 2013, 11:05:35 AM5/9/13
to js-test...@googlegroups.com
I'm now trying completely avoiding globbing in that directory, and just listing all the files, in order, that it should load.  It doesn't appear to make a difference.

The following is my current conf file:

server: http://localhost:9876

load:
 - src/main/webapp/js/*.js
 - src/main/webapp/js/libs/*.js
 - src/main/webapp/js/profiling/*.js
 - src/main/webapp/js/mylibs/config.js
 - src/main/webapp/js/mylibs/controller.js
 - src/main/webapp/js/mylibs/controller.daily.js
 - src/main/webapp/js/mylibs/controller.daily.rate-table.js
 - src/main/webapp/js/mylibs/controller.realtime.subway-map.js
 - src/main/webapp/js/mylibs/data.daily.js
 - src/main/webapp/js/mylibs/html.daily.js
 - src/main/webapp/js/mylibs/html.realtime.matrix-view.js
 
test:
 - src/test/webapp/js/*.js

 
Here's the relevant portion of the log:
Running: java -classpath C:\Users\dk068x\.m2\repository\com\googlecode\jstd-maven-plugin\jstd-maven-plugin\1.3.5.1\jstd-maven-plugin-1.3.5.1.jar;C:\Users\dk068x\.m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\dk068x\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\dk068x\.m2\repository\com\google\jstestdriver\jstestdriver\1.3.5\jstestdriver-1.3.5.jar;C:\Users\dk068x\.m2\repository\org\codehaus\plexus\plexus-component-annotations\1.5.5\plexus-component-annotations-1.5.5.jar;C:\Users\dk068x\.m2\repository\org\sonatype\sisu\sisu-inject-bean\2.3.0\sisu-inject-bean-2.3.0.jar;C:\Users\dk068x\.m2\repository\org\sonatype\sisu\sisu-guice\3.1.0\sisu-guice-3.1.0-no_aop.jar;C:\Users\dk068x\.m2\repository\org\sonatype\sisu\sisu-guava\0.9.9\sisu-guava-0.9.9.jar;C:\Users\dk068x\.m2\repository\org\codehaus\plexus\plexus-utils\2.0.6\plexus-utils-2.0.6.jar;C:\Users\dk068x\.m2\repository\org\codehaus\plexus\plexus-interpolation\1.1\plexus-interpolation-1.1.jar;C:\Users\dk068x\.m2\repository\org\apache\xbean\xbean-reflect\3.4\xbean-reflect-3.4.jar;C:\Users\dk068x\.m2\repository\log4j\log4j\1.2.12\log4j-1.2.12.jar;C:\Users\dk068x\.m2\repository\commons-logging\commons-logging-api\1.1\commons-logging-api-1.1.jar;C:\Users\dk068x\.m2\repository\com\google\code\google-collections\google-collect\snapshot-20080530\google-collect-snapshot-20080530.jar;C:\Users\dk068x\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar;C:\Users\dk068x\.m2\repository\org\codehaus\woodstox\wstx-asl\3.2.6\wstx-asl-3.2.6.jar;C:\Users\dk068x\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\dk068x\.m2\repository\org\sonatype\spice\model-builder\1.3\model-builder-1.3.jar;C:\Users\dk068x\.m2\repository\org\apache\maven\maven-project-builder\3.0-alpha-2\maven-project-builder-3.0-alpha-2.jar -jar C:\Users\dk068x\.m2\repository\com\google\jstestdriver\jstestdriver\1.3.5\jstestdriver-1.3.5.jar --basePath C:\Users\dk068x\workspace6\SunlightGUI --browser C:/Users/dk068x/AppData/Local/Google/Chrome/Application/chrome.exe --captureConsole --config C:\Users\dk068x\workspace6\SunlightGUI\src\test\resources\jsTestDriver.conf --port 9876 --runnerMode QUIET --tests all --verbose

setting runnermode QUIET
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/dd_belatedpng.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.4.2.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.4.2.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.6.4.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery-1.6.4.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.address-1.3.1.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.address-1.3.1.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.browser.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.coo.kie.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jquery.phpdate.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/jstz.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/modernizr-1.6.min.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/libs/underscore.js
Chrome 23.0.1246.0 Windows loaded /test/src/main/webapp/js/mylibs/config.js
[ERROR] error loading file: /test/src/main/webapp/js/mylibs/controller.daily.js:1: Uncaught ReferenceError: Controller is not defined
[ERROR] error loading file: /test/src/main/webapp/js/mylibs/controller.daily.rate-table.js:4: Uncaught ReferenceError: Controller is not defined
[ERROR] error loading file: /test/src/main/webapp/js/mylibs/controller.diagnostic.page.js:1: Uncaught ReferenceError: Datas is not defined
[ERROR] error loading file: /test/src/main/webapp/js/mylibs/controller.js:28: Uncaught ReferenceError: Util is not defined

 It sure doesn't appear to be processing those files in the order they're listed in the conf file.

Nathan Redding

unread,
May 9, 2013, 11:24:43 AM5/9/13
to js-test...@googlegroups.com

Just to eliminate the obvious, it looks like JSTD is loading the config file located at: C:\Users\dk068x\workspace6\SunlightGUI\src\test\resources\jsTestDriver.conf

That is the config file with the explicit listing of files in the order shown above, right?

If you have verified that, would it be possible to create a minimal example project that still exhibits the problem and send it to us?

David Karr

unread,
May 9, 2013, 2:09:41 PM5/9/13
to js-test...@googlegroups.com

Yes, that is the file with that config.

I've tried to construct a zip here with the html files and some other extraneous files removed.  I verified that "mvn install" still fails in the same way.
SunlightGUI.zip

David Karr

unread,
May 9, 2013, 2:27:15 PM5/9/13
to js-test...@googlegroups.com
It sure seems to me that it's not processing these files to load in the order specified in the conf file.  I turned on runnermode DEBUG and I searched in the output for both "controller.daily.js" and "controller.js", and in each set of output that appears to be doing something to all of the files, it always processes the former before the latter.


On Thursday, May 9, 2013 8:24:43 AM UTC-7, Nathan Redding wrote:

Nathan Redding

unread,
May 9, 2013, 4:03:16 PM5/9/13
to js-test...@googlegroups.com
Aha - It would seem the globing is recursive. So, your first line which loads src/main/webapp/js/*.js is actually going through the directories in alphabetical order and causing the .js files in each to load in alphabetical order. I replaced this first line with src/main/webapp/js/plugins.js since that is the only file in the root directory. After doing that, it starts to load them in the order you listed. 

It looks like there is yet a different problem after this, however, as src/main/webapp/js/profiling/config.js is looking for an object named YAHOO.

Hope that helps!

Cory Smith

unread,
May 9, 2013, 4:18:34 PM5/9/13
to JsTestDriver
Looks like '*' is a little to greedy.


--

David Karr

unread,
May 9, 2013, 4:27:08 PM5/9/13
to js-test...@googlegroups.com


On Thursday, May 9, 2013 1:18:34 PM UTC-7, Cory Smith wrote:
Looks like '*' is a little to greedy.

I've concluded that relying on globbing at all is a bad idea.  I got this working by meticulously determining a good enough load order that got through all the required declarations until the test code was able to run (and finally pass), without any globbing at all.
 

Nathan Redding

unread,
May 9, 2013, 4:32:50 PM5/9/13
to js-test...@googlegroups.com
Yeah, generally, you just want to list the files in the same manner your page does. On my last project, I created a Maven plugin that understood our project directory structure and generated the JSTD config file as part of the build.... it worked very well, especially since it was a very large project with a ton of files that would change in number weekly.


--
You received this message because you are subscribed to a topic in the Google Groups "JsTestDriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/js-test-driver/5VXbmjvwNUw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to js-test-drive...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages