templateUrlを使用したAngularJSディレクティブの単体テスト
templateUrl定義されているAngularJSディレクティブがあります。私はそれをジャスミンでユニットテストしようとしています。 私のJasmine JavaScriptは、この推奨に従って、次のようになります。 describe('module: my.module', function () { beforeEach(module('my.module')); describe('my-directive directive', function () { var scope, $compile; beforeEach(inject(function (_$rootScope_, _$compile_, $injector) { scope = _$rootScope_; $compile = _$compile_; $httpBackend = $injector.get('$httpBackend'); $httpBackend.whenGET('path/to/template.html').passThrough(); })); describe('test', function () { var element; beforeEach(function () { element = $compile( '<my-directive></my-directive>')(scope); angular.element(document.body).append(element); }); afterEach(function () …