Skip to content

Commit 72642ca

Browse files
guguclaude
andcommitted
Fix flaky tests caused by unregistered custom SVG icons
Add MatIconTestingModule to tests using components with custom SVG icons (ai_rocket, github). Icons registered in AppComponent weren't available in unit tests, causing intermittent "Unable to find icon" errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 9c575ac commit 72642ca

File tree

4 files changed

+359
-365
lines changed

4 files changed

+359
-365
lines changed
Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
1+
import { provideHttpClient } from '@angular/common/http';
12
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
3-
import { DbTableAiPanelComponent } from './db-table-ai-panel.component';
3+
import { MatIconTestingModule } from '@angular/material/icon/testing';
4+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
45
import { Angulartics2Module } from 'angulartics2';
56
import { MarkdownService } from 'ngx-markdown';
6-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7-
import { provideHttpClient } from '@angular/common/http';
7+
import { DbTableAiPanelComponent } from './db-table-ai-panel.component';
88

99
describe('DbTableAiPanelComponent', () => {
10-
let component: DbTableAiPanelComponent;
11-
let fixture: ComponentFixture<DbTableAiPanelComponent>;
10+
let component: DbTableAiPanelComponent;
11+
let fixture: ComponentFixture<DbTableAiPanelComponent>;
1212

13-
const mockMarkdownService = {
14-
parse: jasmine.createSpy('parse').and.returnValue('parsed markdown'),
15-
};
13+
const mockMarkdownService = {
14+
parse: jasmine.createSpy('parse').and.returnValue('parsed markdown'),
15+
};
1616

17-
beforeEach(async () => {
18-
await TestBed.configureTestingModule({
19-
imports: [
20-
Angulartics2Module.forRoot(),
21-
DbTableAiPanelComponent,
22-
BrowserAnimationsModule
23-
],
24-
providers: [
25-
provideHttpClient(),
26-
{ provide: MarkdownService, useValue: mockMarkdownService },
27-
]
28-
}).compileComponents();
17+
beforeEach(async () => {
18+
await TestBed.configureTestingModule({
19+
imports: [Angulartics2Module.forRoot(), DbTableAiPanelComponent, BrowserAnimationsModule, MatIconTestingModule],
20+
providers: [provideHttpClient(), { provide: MarkdownService, useValue: mockMarkdownService }],
21+
}).compileComponents();
2922

30-
fixture = TestBed.createComponent(DbTableAiPanelComponent);
31-
component = fixture.componentInstance;
32-
fixture.detectChanges();
33-
});
23+
fixture = TestBed.createComponent(DbTableAiPanelComponent);
24+
component = fixture.componentInstance;
25+
fixture.detectChanges();
26+
});
3427

35-
it('should create', () => {
36-
expect(component).toBeTruthy();
37-
});
28+
it('should create', () => {
29+
expect(component).toBeTruthy();
30+
});
3831
});

0 commit comments

Comments
 (0)