第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

單元測(cè)試AngularJS指令與templateUrl

單元測(cè)試AngularJS指令與templateUrl

慕妹3242003 2019-08-15 15:12:48
單元測(cè)試AngularJS指令與templateUrl我有一個(gè)templateUrl定義的AngularJS指令。我正在嘗試用Jasmine進(jìn)行單元測(cè)試。根據(jù)以下建議,我的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 () {                 element.remove();             });             it('test', function () {                 expect(element.html()).toBe('asdf');             });         });     });});當(dāng)我在我的Jasmine規(guī)范錯(cuò)誤中運(yùn)行它時(shí),我收到以下錯(cuò)誤:TypeError: Object #<Object> has no method 'passThrough'我想要的是模板加載原型 - 我不想使用respond。我相信這可能與使用ngMock而不是ngMockE2E有關(guān)。如果這是罪魁禍?zhǔn)祝以撊绾问褂煤笳叨皇乔罢吣??提前致謝!
查看完整描述

3 回答

?
慕慕森

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊

我最終做的是獲取模板緩存并將視圖放在那里。事實(shí)證明,我無(wú)法控制不使用ngMock:

beforeEach(inject(function(_$rootScope_, _$compile_, $templateCache) {
    $scope = _$rootScope_;
    $compile = _$compile_;
    $templateCache.put('path/to/template.html', '<div>Here goes the template</div>');}));


查看完整回答
反對(duì) 回復(fù) 2019-08-15
  • 3 回答
  • 0 關(guān)注
  • 604 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)