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

前端 未结 6 2183
不思量自难忘°
不思量自难忘° 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:52

    Just spent a couple hours on this. It looks like Angular now provides a FakeMatIconRegistry. It squashed about 90% of the karma warnings, but still a few remain...

    Had to do a lot of this:

    TestBed.configureTestingModule({
        declarations: [ MyComponent ],
        imports: [
            ...
            MatIconModule,
        ],
        providers: [
            ...
            { provide: MatIconRegistry, useClass: FakeMatIconRegistry }
        ]
    }).compileComponents();
    

提交回复
热议问题