An another way to include file, to be able to use test command

731 views
Skip to first unread message

Soufyan

unread,
Jul 10, 2012, 10:27:42 AM7/10/12
to casp...@googlegroups.com
Hi everybody,

I use this command "casper test /my/path " to run my functional test suites.

But there are two important conditions for splitting our test suite across several files:
  1. Not to create a new Casper instance in a split test file;

  2. To call the Tester.done() method when all the tests contained in a single file have been executed.

ps : you can read the docs here

My question is about the first condition : I need to include jquery script, How can I do that, because the syntax of including script is as follow :

var casper = require('casper').create({
    clientScripts:  [
        'includes/jquery.js',      // These two scripts will be injected in remote
        'includes/underscore.js'   // DOM on every request
    ],
...
});

there are another way to include files or we must use phantomjs syntax (
page.injectJs("jquery.min.js") ) ?

regards.

Nicolas Perriault

unread,
Jul 10, 2012, 10:43:21 AM7/10/12
to casp...@googlegroups.com
On Tue, Jul 10, 2012 at 4:27 PM, Soufyan <amenzou...@gmail.com> wrote:

> there are another way to include files or we must use phantomjs syntax (
> page.injectJs("jquery.min.js") ) ?

Try with:

casper.options.clientScripts.push("jquery.min.js");

To remove it later if needed:

casper.options.clientScripts =
casper.options.clientScripts.filter(function(script) {
return script !== "jquery.min.js";
});

That's just plain theory, but it should work.

++

--
Nicolas Perriault
https://nicolas.perriault.net/http://www.akei.com/
Skype: nperriault
Phone: +33 (0) 660 92 08 67

Soufyan

unread,
Jul 11, 2012, 4:39:07 AM7/11/12
to casp...@googlegroups.com
Thank you,

casper.options.clientScripts.push("jquery.min.js"); works perfectly.

I haven't tried yet to remove it.

I'll keep you current.

regards
++
Reply all
Reply to author
Forward
0 new messages