I have a directive that is inside a controller. I am trying to write unit tests to test what happens when this code is executed. The code is called not from a click event or anything but from a socket.io
emit. Rather than trying to mock socket.io
I'm trying to call the function directly from casper.js not phantom.js
here is the directive
// exposed to UI with a poniter
scope.testingText = testingText;
function testingText(int, string) {
return int + string;
}
The function I have in the casper suite is:
function callDirectiveJavascript() {
casper.evaluate(function () {
var test = scope.testingText(100, 'string');
console.log('test:' + test);
});
}
The console.log
statement is never evaluated. When I run
casper.on( 'page.error', function (msg, trace) {
this.echo( 'Error: ' + msg, 'ERROR' );
});
scope
is not defined. Trying to figure out how to get access to the scope of my directive.
Any ideas? Beyond just the console.log
, I've seen people calling js
through casper
with this implementation, but haven't seen it specific to angularjs