Currently, I am in the process of conducting unit tests on a directive that was previously created. For my initial test, I simply want to verify a specific variable within the scope of the directive.
However, whenever I attempt to execute the method isolatedScope()
on my HTML element, I encounter an error message stating that
elem.isolatedScope is not a function
.
Interestingly, when I insert a breakpoint immediately after calling $compile
on my element, I can successfully display the isolated scope of the directive through the JavaScript console.
Even if I try to assign my isolatedScope
to a variable as shown below, I consistently face the issue where
elem.isolatedScope is not a function
.
describe('directive: wikis', function() {
var $scope, elem, isolated;
beforeEach(module('app'));
beforeEach(inject(function(_$compile_, _$rootScope_){
$scope = _$rootScope_.$new();
elem = angular.element('<wikis></wikis>');
elem = _$compile_(elem)($scope);
isolated = elem.isolatedScope()
isolated.$digest();
}));
describe('$scope should be defined', function(){
it('data should be empty object', function() {
expect(isolated.data).to.be.null;
});
});
});
Could you provide any insights or suggestions on what could potentially be causing this issue?