<\/script>')

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!

+3
source share
2 answers

The CasperError: casper.test property is available only with the casperjs test command casperjs 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 
+7
source

you can also call casperjs test xyz.js

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

0
source

Source: https://habr.com/ru/post/975056/


All Articles