Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Compatibility with jQuery Mobile #204

Closed
sdesalas opened this Issue · 4 comments

4 participants

@sdesalas

I'm just in the middle of implementing some Jasmine tests for a jQuery mobile application I'm working on, I've run into an error that I managed to track down to adding the jQuery mobile library, the error is as follows:

Jasmine.js:1769 TypeError: Cannot read property 'abort' of undefined.

As soon as I remove the jQM dependency, the error goes away.

This is my code:

<!DOCTYPE html>
<html>
<head>
<title>HTML5/Common/Tests</title>
<!-- LOAD STYLES FIRST -->
<link type="text/css" rel="stylesheet" href="libs/jasmine.css" media="screen">
<link type="text/css" rel="stylesheet" href="../../Common/libs/jquery.mobile-1.0.1.css" />
<!-- LOAD JASMINE LIBRARIES -->
<script type="text/javascript" src="libs/jasmine.js"></script>
<script type="text/javascript" src="libs/jasmine-html.js"></script>
<!-- LOAD DEPENDENCIES -->
<script type="text/javascript" src="../../Common/libs/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../../Common/libs/jquery.mobile-1.0.1.min.js"></script>
<!-- LOAD CODE TO TEST -->
<script type="text/javascript" src="../../Common/libs/myLib.js"></script>
<!-- LOAD ACTUAL TESTS -->
<script type="text/javascript">
describe("Suite 1", function() {
it("Should be that 1 equals 0", function() {
expect(1).toEqual(0);
});
});
</script>
</head>
<body>
<script type="text/javascript">
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().execute();
</script>
</body>
</html>

I'd prefer to use Jasmine for this application instead of qUnit as I think its more flexible and easier to implement in CI and explain to the BA's and PM's.. however after tinkering with this problem for a couple of hours and some futile searches on google I still havent been able to solve it so I'm starting to consider moving on.

Here is the stack-overflow URL in case there is a workaround come up from the discussion or whoever solves it wants to claim brownie points there:

http://stackoverflow.com/questions/9784504/jasmine-throwing-up-an-error-with-jquery-mobile

Thanks and Regards.

@ragaskar
Owner

Can you paste in the context around line 1769 of the jasmine.js that you're using? It doesn't appear to be HEAD. If I had to guess I'd say it's this line:

if (self.blocks[self.index].abort) {
self.abort = true;
}

which suggests some of your blocks might be empty?

I also notice you're jasmine.getEnv().execute()-ing without waiting for the DOM page ready to fire. Try wrapping your execute in $(function() { }) to wait until the page ready fires and see if that helps (refer to the example for more info).

@sdesalas

Hi ragaskar,

Thanks for your prompt response and your help. Yep thats correct the line causing the error is in 'jasmine.Queue.prototype.next_' code below:

if (self.blocks[self.index].abort) {
self.abort = true;
}

I looked at the execution scope and 'self' was of type jasmine.Queue, 'self.blocks' was an Array[1] and 'self.index' was 1 too, thus causing the error.

I tried wrapping the .execute() inside a $(document).ready(function() { ... }); to await for all scripts to load and execute and it still fires off the same error.

For my first test there was only a single test inside a test block as follows so I'm unsure what is causing it:

describe("Suite 1", function() {
it("Should be that 1 equals 0", function() {
expect(1).toEqual(0);
});
});

My only guess is that this is somehow related to the extensive DOM manipulation carried out inside jQueryMobile, which basically walks through the HTML page and recreates the DOM and applies styling according to special formatting rules based on data-role="X" attributes. Im not sure wether this is helpful but you can read more on:

http://jquerymobile.com/demos/1.1.0-rc.1/docs/about/getting-started.html

Try right-click and 'Inspect Element' on one of the formatted lists there and you'll see what I mean.

@infews
Owner

We've changed how the queuing of functions works pretty drastically on master.

Can you take a look and see if the problem persists?

@slackersoft
Owner

Closing for now. Please let us know/reopen this if this is still an issue for you.

@slackersoft slackersoft closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.