Angular 6 unit testing component with DomSanitizer dependency

后端 未结 2 1521
情话喂你
情话喂你 2021-02-07 19:42

In a unit test to just create (instantiate) a component that has a DomSanitizer dependency, how does one mock / stub this dependency?

Because DomSanit

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 20:17

    As a workaround, try add sanitize: () => 'safeString',

    ...
    useValue: {
      sanitize: () => 'safeString',
      bypassSecurityTrustHtml: () => 'safeString'
    }
    ...
    

提交回复
热议问题