You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. create a tmp folder, copy in jquery-1.3.1.js
2. create a file named test_docready.js that looks like:
TestCase("TestDocready", {
test_docready: function() {
expectAsserts(1);
var counter = 0;
$(document).ready(function(){
counter += 1;
});
$(document).ready(function(){
assertEquals(counter, 1);
});
}
});
3. create a conf that looks like:
server: http://localhost:4224
load:
- jquery*.js
- test*.js
4. start the server as normal : java -jar ~/src/JsTestDriver-1.0b.jar
--port 4224 --captureConsole
5. Open some browsers to http://127.0.0.1:4224/capture
6. Run the tests as you would normally: java -jar
~/src/JsTestDriver-1.0b.jar --tests all
What is the expected output? What do you see instead?
I'd think that $(document).ready(fn) would fire like normal but instead the
tests fail, indicating that ready(fn) never fires:
FF
Total 2 tests (Passed: 0; Fails: 2; Errors: 0) (2.00 ms)
Safari 525.28.3: Run 1 tests (Passed: 0; Fails: 1; Errors 0) (0.00 ms)
TestDocready.test_docready failed (0.00 ms): Expected '1' asserts but
'0' encountered.
Firefox 1.9.0.10: Run 1 tests (Passed: 0; Fails: 1; Errors 0) (2.00 ms)
TestDocready.test_docready failed (2.00 ms): Expected '1' asserts but
'0' encountered.
*However* if I swap out jquery-1.3.1.js for jquery-1.2.6.js then the test
passes in Safari only:
.F
Total 2 tests (Passed: 1; Fails: 1; Errors: 0) (1.00 ms)
Safari 525.28.3: Run 1 tests (Passed: 1; Fails: 0; Errors 0) (1.00 ms)
Firefox 1.9.0.10: Run 1 tests (Passed: 0; Fails: 1; Errors 0) (1.00 ms)
TestDocready.test_docready failed (1.00 ms): Expected '1' asserts but
'0' encountered.
What version of the product are you using? On what operating system?
Please provide any additional information below.
If you know of a workaround (maybe manually triggering jquery's ready
functions?) then let me know because I can't think of another way to use
js-test-driver to test jquery code.
Original issue reported on code.google.com by kumar.mcmillan on 27 May 2009 at 2:36
The text was updated successfully, but these errors were encountered:
Hi Kumar,
We already load jquery, could you try the same test without loading your own
version
of jquery?
Also, we are not reloading the document every time, we only reload the
javascript
that changed so this event will not be fired. Why not call your callback
directly
from your test?
Let me know if it helps.
Thanks !
Original comment by toc...@gmail.com on 27 May 2009 at 10:51
Aha, removing the line in my conf that was loading jquery did indeed fix the
problem.
Thanks! You may want to add this to the docs and also note the version of jquery
that will be preloaded.
By the way, the test above passes every time. In other words, your reload code
preserves the functionality of calling $(document).ready(fn).
Why not call my callback directly? There are a few reasons. One is that I was
actually trying to test an initialization function that will wrap the input in
$(document).ready() based on some conditions. And the other is that a lot of
configuration code is wrapped in anonymous functions because so much of it must
run
only at ready() time.
Original comment by kumar.mcmillan on 28 May 2009 at 12:43
Original issue reported on code.google.com by
kumar.mcmillan
on 27 May 2009 at 2:36The text was updated successfully, but these errors were encountered: