angularjs - Template-Url Directive Unit Testing without Karma -
solution = solution plunker
i have tried manually passing template in testing - way of doing ? how create passes !!!!!!!
how write unit test simple directive template-url without using karma . have tried next after seeing examples on stack-overflow no success.
directive
app.directive("crazy", function () { homecoming { restrict: "a", templateurl:"directivetemplate.html" }; });
spec
describe('directive: crazy', function () { beforeeach(module('plunker')); beforeeach(inject(function($templatecache) { var directivetemplate = null; var req = new xmlhttprequest(); req.onload = function() { directivetemplate = this.responsetext; }; req.open("get", "directivetemplate.html", false); req.send(); $templatecache.put("directivetemplate.html", directivetemplate); })); it('should exist', inject(function ($rootscope, $compile) { element = angular.element('<div crazy></div>'); element = $compile(element)($rootscope); $rootscope.$apply(); expect(element.children().length.tobe(2)); })); });
angularjs unit-testing angularjs-directive angularjs-scope jasmine
No comments:
Post a Comment