I have a pipe that sanatises HTML as below:
import { Pipe, PipeTransform } from \'@angular/core\';
import { DomSanitizer } from \'@angular/platform-browser\';
@
Because of the DI in your pipe, you need to configure a test environment (test bed) to resolve the dependency:
import { BrowserModule, DomSanitizer } from '@angular/platform-browser';
import { inject, TestBed } from '@angular/core/testing';
describe('SanitiseHtmlPipe', () => {
beforeEach(() => {
TestBed
.configureTestingModule({
imports: [
BrowserModule
]
});
});
it('create an instance', inject([DomSanitizer], (domSanitizer: DomSanitizer) => {
let pipe = new SanitiseHtmlPipe(domSanitizer);
expect(pipe).toBeTruthy();
}));
});