Export to GitHub

js-test-driver - issue #4

yui compatibility problem? not all tests are discovered on first load


Posted on May 27, 2009 by Quick Camel

What steps will reproduce the problem? 1. Unpack attached file 2. Run tests with '--config JsTestDriver.conf' 3. Profit?

What is the expected output? What do you see instead?

The expectation is that 120 tests should be found. Instead, on the first run, only 50 tests are found. A subsequent run finds 120 tests (though many of them are failing at the moment).

What version of the product are you using? On what operating system?

JsTestDriver-1.0b.jar, Firefox 1.9.10 on Ubuntu 9.04

Please provide any additional information below.

Attachments

Comment #1

Posted on May 29, 2009 by Happy Rabbit

(No comment was entered for this change.)

Comment #2

Posted on May 29, 2009 by Happy Rabbit

ok so far I see problems with a few files that can not load, which could explain the problem, I have a feeling it might be the order in which the files are ordered that might be incorrect.

The output for me:

error loading file: src/testing/testing.js:27 Expected '(' error loading file: src/overlay/tests/overlay.js:209 Expected identifier, string or number error loading file: src/autocomplete/tests/test.js:587 'lazr.testing.Runner' is null or not an object error loading file: src/activator/tests/activator.js:246 'lazr.testing.Runner' is null or not an object

Comment #3

Posted on May 29, 2009 by Happy Rabbit

it looks like YUI is dynamically loading files and that's probably causing the problem. I need to check how this process work and what I can do so the dynamic loading talks properly to the JsTestDriver server.

Comment #4

Posted on May 30, 2009 by Happy Rabbit

YUI dynamically loading files is the issue... It looks like if I add all the js files needed to the JsTestDriver.conf it will stop loading these files which is good. I tried to also add the css files to the JsTestDriver.conf but it still tries to load them anyway (which I can understand as contrary to a js file that can register a module, there is nothing doing this for a css file and they must base their decision of loading a css file purely on the href of the link tag). If I go in the YUI code and changes the code for their loader to tell it to only load javascript files dynamically and no css files the first times the tests run they are all running (the 120 and not a random number). So something happens when the css files are dynamically loaded that confuses JsTestDriver, I don't fully understand yet what's going on. Anyway even when the 120 tests run there is still a big number of errors and I haven't investigated those yet.

Comment #5

Posted on Jun 2, 2009 by Happy Rabbit

I understand what's going working on a fix. The problem happens because I assume that when the javascript file is loaded (and I get the onload/onreadystatechange event) that we are ready to go and run. In your code though first YUI downloads dependencies and they must set a timeout and call your method that creates the TestCase after that and because I already got the onload event I'm starting running test when the TestCase hasn't been created for the file yet.

Comment #6

Posted on Jun 2, 2009 by Happy Rabbit

Hi Sidnei,

Could you try to sync to HEAD and copy the file src/com/google/jstestdriver/javascript/compat/yui-patch.js into the lazr-js directory and replace your JsTestDriver.conf file with the one attached?

It should fix your problem, I still see errors with your tests though...

Attachments

Comment #7

Posted on Jun 8, 2009 by Quick Camel

Hi there,

I've synced the latest JsTestDriver, ran 'ant' to build the .jar and then started the server. That went fine. When starting the client though to run the tests I get this:

com.google.gson.JsonParseException: Failed parsing JSON source: java.io.StringReader@2cb49d to Json

Ant is: Apache Ant version 1.7.1 compiled on November 10 2008

Java is: java version "1.6.0_0" OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu7) OpenJDK Server VM (build 14.0-b08, mixed mode)

OS: Ubuntu Jaunty (9.04)

Comment #8

Posted on Jun 8, 2009 by Quick Camel

Ok, ignore me. This is running fine. Not sure what I've changed though, seems like I was passing http://127.0.0.1:4224/ as the server, changing that to http://localhost:4224 seemed to fix the problem.

Comment #9

Posted on Jun 8, 2009 by Happy Rabbit

the javascript changed a little bit, it might be that your browser cached the javascript?

Comment #10

Posted on Jun 9, 2009 by Quick Camel

I confirm that this is working great now with the yui-patch.js and latest JsTestDriver from trunk!

Comment #11

Posted on Jun 9, 2009 by Happy Rabbit

Awesome !

I'd like to add a wikipage on the subject, would you want to help me with writing it?

Comment #12

Posted on Jun 9, 2009 by Quick Camel

Sure, just create a boilerplate page and I will fill with the details.

Comment #13

Posted on Jun 9, 2009 by Massive Elephant

seems like Dojo might have a similar problem since they also load dependencies dynamically. was your patch YUI specific or should it work for Dojo as well?

Comment #14

Posted on Jun 10, 2009 by Happy Rabbit

It was a YUI specific patch, I will need to look into it for Dojo.

Comment #15

Posted on Jun 10, 2009 by Massive Elephant

Just to add more clarification to the Dojo issue. My main concern is with loading the source files. When we load up our project in development/debug mode we only reference our root js file. That file has dojo.require calls that load up any dependencies and it chains down through all of the files until there are no more dependencies.

1)The test cases shouldn't run until all dojo dependencies have finished being loaded

2)Ideally JsTestDriver would be able to tell when a dynamically loaded file was updated and re-load it.

Comment #16

Posted on Jun 11, 2009 by Happy Rabbit

The thing is we want JsTestDriver to take care of all the loading (that's how we solved the problem with YUI) as we need to be able to reload files as we need. It should work the same way as YUI and just patch Dojo to prevent it from downloading dependencies.

I'm going to open a new issue to track this and close this one.

Comment #17

Posted on Jun 26, 2009 by Quick Camel

This patch might need to be updated for YUI3 beta1

Comment #18

Posted on Jan 27, 2010 by Happy Hippo

could you tell me where this wiki page is located?

Comment #19

Posted on Feb 1, 2011 by Happy Ox

For folks following this from the dojo side, the new JSTD issue tocman created for JSTD and Dojo is at http://code.google.com/p/js-test-driver/issues/detail?id=12 and the (old) dojo thread discussing it is at https://groups.google.com/d/topic/dojo-interest/Xx5YWO4sBZA/discussion.

Status: Fixed

Labels:
Type-Defect Priority-Medium