Starting with version 1.1, CasperJS relies on its own phantomJS require () :
https://groups.google.com/forum/#!topic/phantomjs/0-DYnNn_6Bs
Injection Dependence
When introducing additional modules, CasperJS looks for a path relative to the cur directory (the place where we run the casperjs command). We can introduce a dependency using the clientScripts option. However, nested dependencies cannot use require globally. They are immediately entered on each loaded page.
casper.options.clientScripts = ["path/relative/to/cur/dir"]
We can also enter modules using the args command line:
casperjs test --includes=foo.js,bar.js path/to/the/test/file
Using require
To import custom modules, use:
require "./user-module.coffee"
Then in custom modules you can also use require. Use of the required paths is permitted relative to the current file (where the call is required).
If in the user module you want to import casper libraries, you need to pay , check: https://casperjs.readthedocs.org/en/latest/writing_modules.html
source share