I'm using Node.js with Express and Jade in my web application, with AngularJS on top.
Usually, when I build directives, I include Html in the template of the directive definition, and then I test the directive writing the Html snippet I need.
But now I have to write a directive that includes a very long HTML, so I'm using the templateUrl
: moreover I want to do it using Jade. So the code looks like this:
[...]
.directive('myDirective', function () {
return {
restrict: 'E',
templateUrl: '/snippet',
link: function (scope, element, attrs) {
// some code
}
};
});
Where the server handle the call to /snippet
with this:
app.get('/snippet', function (req, res) {
res.render('templates/mySnippet', {},
function (err, rendered) {
if (!err)
res.status(200).send(rendered);
});
});
So my problem is: how can I test this directive? I usually make unit test with Karma and Mocha/Chai: does it exist any plugin for karma that can take the jade file, process it and serve it as a fake server when my directive will search for /snippet
?