Executing the PhantomJS API

I'm writing javascript tests using Jasmine and have opted for running them using PhantomJs, but it seems none of the phantomjs api methods will execute successfully from what I can tell. For example, this fails

/// <reference path="../jasmine/jasmine.js"/>

describe("A suite is just a function", function() {
    var a;

    var page = require('webpage').create();

    it("and so is a spec", function() {
        a = true;

        expect(a).toBe(true);
    });
});



but this succeeds


describe("A suite is just a function", function() {
    var a;

    it("and so is a spec", function() {
        a = true;

        expect(a).toBe(true);
    });
});



What am I doing wrong?

Thanks for your time everyone,
Aeden

2 comments
Comment actions Permalink

Can you execute them succesfully in browser via the "normal" html Jasmin Spec Runner? I suggest you try that first. (AFAICT from   http://pivotal.github.com/jasmine/  "require" is not even a part of jasmine?)

0
Comment actions Permalink

I cannot execute the test that contains the creation of the WebPage object via the "normal" html Jasmin Spec Runner because that's part of the PhantomJS API. I can successfully run the test that doesn't.  You're rigth that require is not a part of Jasmine so I tried to run this test instead,

/// <reference path="../jasmine/jasmine.js"/>


describe("A suite is just a function", function() {
    var a;

    var page = new WebPage();

    it("and so is a spec", function() {
        a = true;

        expect(a).toBe(true);
    });
});



but that doesn't work either.
0

Please sign in to leave a comment.