wrap your directive in a div like:
describe('Directive: custom', function () { beforeEach(module('App')); var element, $scope; it('should be transformed to <img>', inject(function ($rootScope, $compile) { $scope = $rootScope.$new(); element = angular.element('<div><custom-directive></custom-directive></div>'); element = $compile(element)($scope); expect(element.children('img').length).toBe(1); })); });
source share