In a unit test to just create (instantiate) a component that has a DomSanitizer
dependency, how does one mock / stub this dependency?
Because DomSanit
As a workaround, try add sanitize: () => 'safeString',
...
useValue: {
sanitize: () => 'safeString',
bypassSecurityTrustHtml: () => 'safeString'
}
...
If you want to preserve the value, use:
{
provide: DomSanitizer,
useValue: {
sanitize: (ctx: any, val: string) => val,
bypassSecurityTrustResourceUrl: (val: string) => val,
},
}