mercredi 28 janvier 2015

How to import other js files in casperjs

Basically,I have extracted the re-usable functions into a file 'utility.js'.I want to import this file into each test script.I'm following the documentation here


When i try the above mentioned approach,I'm getting the following error.



'undefined' is not a function



Folder structure is like this



utility.js
test1.js
test2.js


Test file has following code as suggested by the above documentation



var require = patchRequire(require);
var helper = require('utility');


and I access the function in utility.js as follows helper.fn_do_something()


I tried to use other methods provided by casperJS,like



casper.options.clientscript = [relativepath];


But that didn't help.I'm getting the same error.


I'm using PhantomJS 1.9.8.


Aucun commentaire:

Enregistrer un commentaire