Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

casperjs - Using casper.options and specifically injecting casper clientScripts using casper.tester

Tags:

casperjs

The docs strate you can pass an options object to casperjs.create() including js clientScripts to inject to the client page.

The docs also state that you shouldn't casper.create instance in a test file.

The docs don't state (at least I couldn't find it) how to use an options object with the casper.tester class. I did try to do something like:

casper.options = {
    clientScripts:[
        '../testlib/sinon-1.7.3.js'
        ],
    logLevel:"warning",
    verbose:true

};  

Before casper.test.begin but it broke the test.

putting it between the test.begin and casper.start.

casper.test.begin('Basic index.html elements test',14, function suite(test){
    casper.options..etc
    casper.start(url, function(){
    //also tried here

and also beneath it also broke the tests

I,ll be glad for any direction with this. Especially with the injection part

like image 320
alonisser Avatar asked Sep 09 '13 21:09

alonisser


1 Answers

You will need to push the file onto casper.option.clientScripts so as not to disrupt the other options that casper test sets.

casper.options.clientScripts.push("../testlib/sinon-1.7.3.js");

Source: CasperJS mailing list

like image 69
hexid Avatar answered Oct 31 '22 18:10

hexid