mardi 4 août 2015

Call AngularJS Function from CasperJS

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

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 () {
        console.log('hello?');
        var test = scope.testingText(100, 'string');
        console.log('test:' + test);
    });
}

Neither of the console.log statements are getting evaluated.

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

Aucun commentaire:

Enregistrer un commentaire