unit testing typescript directive template karma-jasmine, html is not defined

前端 未结 1 1091
一整个雨季
一整个雨季 2021-01-22 16:00

Recently i started unit testing on my typescript code using karma-jasmine. After creating and running test case for a service and a simple directive, i created one test case for

相关标签:
1条回答
  • 2021-01-22 16:38

    I needed to make a mock for facadeService.

    Demo mocks.ts

    import {IfcFacadeService} from 'filePath'
    
    export const facadeServiceMock: IfcFacadeService {
    
        methodName: (): any => {}; 
    
    }
    

    To use this mock, import it

    Demo .html.spec.ts

    import {facadeServiceMock} from 'mockPathName'
    
    beforeEach(()=>{
    angular.mock.module(appName), {FacadeService: facadeServiceMock});
    })
    
    0 讨论(0)
提交回复
热议问题