How do I add svg files via MatIconRegistry in unit tests?

前端 未结 6 2029
不思量自难忘°
不思量自难忘° 2021-02-05 10:16

I\'m currently implementing \'unit testing\' in my angular application. However, if I run them, I receive multiple warnings/errors similar to this one: \'Error retrieving

6条回答
  •  隐瞒了意图╮
    2021-02-05 10:46

    can just do:

    ...
    import { MatIcon } from '@angular/material/icon';
    import { MatIconTestingModule } from '@angular/material/icon/testing';
    
    describe('MyComponent', () => {
      ...
    
      beforeEach(async(() => {
        TestBed.configureTestingModule({
          declarations: [MyComponent, MatIcon],
          imports: [MatIconTestingModule],
        }).compileComponents();
      }));
    
    ...
    
    });
    

    This will generate a test icon rendering without the http request

提交回复
热议问题