3

So I have a file running in node which runs a local copy of PhantomJS as below shows:

phantom.casperPath = 'node_modules/casperjs';
phantom.injectJs('node_modules/casperjs/bin/bootstrap.js');
var casper = require('casper').create({
    viewportSize: config.viewportSize
});

casper.test.begin('Runing tests here', 5, function suite(test) {
    // Tests here
});

Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following error in my console:

CasperError: casper.test property is only available using the `casperjs test` command

The CasperJS docs mentions this too: http://docs.casperjs.org/en/latest/testing.html. My question is how do I run this Casper under this command in the above code so I can use these tests?

Thanks!

Matt Derrick
  • 5,674
  • 2
  • 36
  • 52

2 Answers2

7

CasperError: casper.test property is only available using the casperjs test command

problem solved.

You have to include this line at the top of your script in your xyz.js, so that the .test property becomes true;

phantom.casperTest = true;

Then you should have no problem Launching from the terminal:

casperjs xyz.js
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
PhilippeThomas
  • 141
  • 1
  • 9
  • In my reading of bootstrap.js, I see the setting of casperTest, but quite a number of things are done. This answer was not sufficient in my use case of running capserjs from a phantomjs REPL. – Ian Tegebo Feb 05 '14 at 00:11
0

you can also call casperjs test xyz.js

For more info, check the doco here : http://docs.casperjs.org/en/latest/testing.html

Linx8
  • 64
  • 4