unit testing Typoskript Direktiven Vorlage Karma-Jasmin, HTML ist nicht definiert

or kurzem habe ich angefangen, meinen Typoskript-Code mit Karma-Jasmin zu testen. Nachdem ich einen Testfall für einen Dienst und eine einfache Anweisung erstellt und ausgeführt habe, habe ich einen Testfall für eine benutzerdefinierte Anweisung erstellt, die einen Controller (der einen Dienst einspeist) und 4 Bereichsvariablen für die Kommunikation mit der Außenwelt verwendet.

Es ist ein einfacher Unit-Testfall, um zu überprüfen, ob die Vorlage von der Direktive gerendert wird oder nicht.

Während dieser Einheitentestfall ausgeführt wird, gibt Karma einen Fehler aus

09 03 2016 19:59:27.056:INFO [framework.browserify]: bundle built
09 03 2016 19:59:27.063:INFO [karma]: Karma v0.13.21 server started at http://localhost:9876/
09 03 2016 19:59:29.964:INFO [Chrome 49.0.2623 (Linux 0.0.0)]: Connected on socket /#4OCi116hP6TDqCsmAAAA with id manual-1348
LOG: Object{0: <normal-directive></normal-directive>, length: 1}
Chrome 49.0.2623 (Linux 0.0.0) normal should render the template FAILED
Error: [$injector:unpr] Unknown provider: FacadeServiceProvider <- FacadeService
http://errors.angularjs.org/1.5.0/$injector/unpr?p0=FacadeServiceProvider%20%3C-%20FacadeService

//some reference to file
TypeError: Cannot read property 'html' of undefined
    at Object.<anonymous> (/tmp/5c59a59c62f48798a123b52b0468515b.browserify:476:23

Während ich es debugge, erfahre ich, dass es "Normal-Direktive" als normalen Text betrachtet, nicht als HTML-Tag.

normal-Directive.spec.ts

import {appName} from '../../../../main';
import NormalController from '../../../../components/normalManager/normalList/NormalController';

describe('normalManager.normalList', () => {
    let $compile:angular.ICompileService,
        $rootScope:any,
        template:angular.IAugmentedJQuery,
        element:angular.IAugmentedJQuery,
        controller:NormalController,
        controllerSpy:jasmine.Spy;

    beforeEach(() => {
        angular.mock.module(appName);

        inject((_$compile_:ng.ICompileService, _$rootScope_:ng.IRootScopeService) => {
            $compile = _$compile_;
            $rootScope = _$rootScope_;
        });

        template = angular.element('<div normal-directive></div>');
        element = $compile(template)($rootScope);//getting error on this line.
        controller = element.controller('normalList');

        $rootScope.$digest();
    });

    it('should render the component', () => {
        expect(element.html()).toContain('<!-- normalManager.normalList -->');
    });
});

normal-Directive.ts

import * as angular from 'angular';
import {normalController} from './normalController';
import {html} from './normal.html'

module normal {
    "use strict";
    export class normal {
        public link: (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => void;
        public template = html;
        public scope = {
            ngNormalVariables: '=',
            ngNormalData: '=',
            ngDifferentType: '=',
            ngType: '='
        };
        public restrict: string = 'EA';
        public controller =  normalController;
        public controllerAs: string =  'vm';
        public bindToController:boolean =  true;

        constructor() {
            normal.prototype.link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => {

            };
        }

        public static Factory() {
            var directive = () => {
                return new normal();
            };

            directive['$inject'] = [];
            return directive;
        }
    }
}

export default normal;

normalController.ts

import {IfcNormalFacadeService} from '../../../normal_core/services/NormalFacadeService/IfcNormalFacadeService'
export class normalController {
    //Variable injection
    private normalFacadeService: IfcNormalFacadeService;

    public xVariableVal = null;
    public yVariableVal = null;

    //Scope variables
    private ngNormalData = {x:null, y:null, t:null, z:null};
    private ngNormalVariables = {x: [], y:[], t:[], z:[]};
    private ngType = null;
    private ngDifferentType = null;

    constructor(normalFacadeService: IfcNormalFacadeService) {
        console.log("Inside Normal controller");
        this.normalFacadeService = normalFacadeService;
    }

    ....//Remaining code
}

Ich beziehe mich aufDie repo, um Testfall- und Typenskript-Code für benutzerdefinierte Anweisungen zu schreiben.

Wenn Sie weitere Informationen benötigen, sagen Sie es mir. Wenn Sie einen konkreten Blog / eine konkrete Website kennen, auf der Sie mehr über das Testen von Karma-Jasmin-Einheiten auf Typoskripte erfahren können, teilen Sie mir dies bitte mit.

ielen Dank für Ihre wertvolle Zeit beim Lese

Grüß

Ajay

Antworten auf die Frage(2)

Ihre Antwort auf die Frage