Sunday, 18 August 2013

casperjs: how to include dependencies for unit tests in tests themselves?

casperjs: how to include dependencies for unit tests in tests themselves?

I am doing some unit test in casperjs and I got stuck: how do include
dependency file from the test itself? I know I can include from the
command line
$ casperjs test --include=./my-mock.js mytest.js
but how can I include files from the test itself?
Putting following on the top does not work for me... my_mock is undefined
casper.options.clientScripts = ["./my-mock.js"]; //push() does not help
either
//mytest.js is below
// ------------------------------------------
casper.test.begin('ajax mock test', function suite(test) {
my_mock.setFetchedData("bla");
my_mock.doRequest();
test.assertEquals( ......);
test.done();
});
// ------------------------------------------
CasperJS version 1.1.0-DEV using phantomjs version 1.9.1

No comments:

Post a Comment