title: Jasmine doesn't recognize Angular's DomSanitizer
body: <p>I am unit testing an Angular 5 app with Jasmine. I got to the point where I need to test a function that relies on the <code>DomSanitizer</code>:</p>
  
  <pre><code>loadImage() {
    this.image = this.sanitizer.bypassSecurityTrustStyle(`url(${this.assetUrl})`);
  }
  </code></pre>
  
  <p>I verified that this function works perfectly, meaning that <code>DomSanitizer</code> is already in the constructor and it's syntax is correct. </p>
  
  <p>My unit test is as follows:</p>
  
  <pre><code>it('loads the Image', () =&gt; {
      component.loadImage()
      fixture.detectChanges();
      expect(component.imageUrl).toBe('...');
    });
  </code></pre>
  
  <p>Moreover, <code>DomSanitizer</code> is part of the <code>TestBed</code> <code>providers</code>:</p>
  
  <pre><code>beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [
          RouterTestingModule,
          CommonModule
        ],
        declarations: [
          MyComponent
        ],
        providers: [
          DomSanitizer
        ],
        schemas: [ NO_ERRORS_SCHEMA ]
      })
      .compileComponents();
    }));
  </code></pre>
  
  <p>Yet, Jasmine throws this error when unit-testing the function:</p>
  
  <pre><code>ERROR: 'Unhandled Promise rejection:', '_this.sanitizer.bypassSecurityTrustStyle is not a function', '; Zone:', 'angular', '; Task:', 'Promise.then', '; Value:', TypeError: _this.sanitizer.bypassSecurityTrustStyle is not a function
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!</p>