Running "casperjs test" in phantom
So, I have a file running in node that runs a local copy of PhantomJS, as shown below:
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 casper.test.begin() my tests work fine. I have the correct version 1.1.0 that 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 CasperJS docs also mention the following: 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 that I can use these tests?
Thanks!
The CasperError: casper.test property is available only with the
casperjs testcommandcasperjs test
the problem is resolved.
You must 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 not have a problem. Starting from the terminal:
casperjs xyz.js you can also call casperjs test xyz.js
For more information, check out the doco here: http://docs.casperjs.org/en/latest/testing.html