私は以前に書かれたディレクティブを単体テストしようとしています。私がやりたいことは、ディレクティブのスコープ内で変数をチェックするだけです。ユニットテストディレクティブとisolatedScopeは関数ではない
ただし、私のhtml要素にisolatedScope()
メソッドを実行しようとするたびに、エラーelem.isolatedScope is not a function
が表示されます。
奇妙なことの1つは、私が$compile
を私の要素のjavascriptコンソールから実行した直後にブレークポイントを設定すると、私はディレクティブの分離されたスコープを出力できます。
isolatedScope
に以下の変数を設定しようとすると、エラー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;
});
});
});
私は何が間違っているかもしれないと思いますか?
isolateScopeは廃止されました(角度1.3?)ので、以前のバージョンを使用していない限り動作しません。 – rrd