FuncUnit failing to run tests with PhantomJS

173 views Asked by At

I've been trying to create a series of functional unit tests to be run on a Node.js web server using PhantomJS as a browser, testing functionality on another site. I've had success using FuncUnit in the past to run functional tests from the target site itself, but in order to test scale, I've created a Node project to do this, run on a Heroku instance.

I've used Bower to install JQuery, Jasmine (the test runner I'm using), and FuncUnit. I've been informed that FuncUnit does not support the most recent version of Jasmine, so it is at version 1.3.1 - all other packages are at their latest version. Phantom has been installed with NPM, and opens the following page:

<html>
<head>
<title>Functional Testing</title>

<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/syn/dist/syn.js"></script>
<script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/json2.js"></script>
<script type="text/javascript" src="bower_components/funcunit/dist/funcunit.js"></script>

<script type="text/javascript" src="testSpec.js"></script>

<script type="text/javascript">
   // Standard Jasmine 1.3 boot script from examples
</script>

</head>

<body>
</body>
</html>

I run into errors almost immediately once the test run starts. The below section seems to cause crashes, though I've had difficulty figuring out which line exactly as the stack trace has proven difficult to navigate.

F.attach(jasmine);

F.speed = 100;

describe("Demo Script", function() {
    "use strict";

    it("should login to the website", function() {

        F.open("http://example.site/login");

        if (F('h2:contains("ALL PROJECTS")').size() === 0) {
            // Not logged in

            F('#Email').visible().type("[email protected]");
        }
    });
});

This produces an error with the following description:

TypeError: 'undefined' is not an object (evaluating 'off.left') 
    file:///app/bower_components/funcunit/dist/funcunit.js:290
    file:///app/bower_components/funcunit/dist/funcunit.js:473
    file:///app/bower_components/funcunit/dist/funcunit.js:120 
    file:///app/bower_components/funcunit/dist/funcunit.js:91           
    file:///app/bower_components/funcunit/dist/funcunit.js:2852            
    file:///app/bower_components/funcunit/dist/funcunit.js:3240

The top line of this stack trace points to the following function:

//syn.helpers.addOffset
addOffset: function (options, el) {
    var jq = syn.jquery(el), off;
    if (typeof options === 'object' && options.clientX === undefined && options.clientY === undefined && options.pageX === undefined && options.pageY === undefined && jq) {
        el = jq(el);
        off = el.offset();
        options.pageX = off.left + el.width() / 2;
        options.pageY = off.top + el.height() / 2;
    }
}

It seems that el is passed into this function as undefined, but trying to investigate the source of this call has left me stumped. If anyone can see missing script references or anything wrong with my test specification that might cause this, it'd be much appreciated. Thanks!

Edit

I've just noticed that if I leave it running, this error re-occurs every 30 seconds or so.

0

There are 0 answers