Skip to content

Commit 74be058

Browse files
committed
test(header): always restore real timers to prevent flaky cascade
The 'should reorder columns on drag' test enables fake timers but only restores them after its assertions. When a layout-timing-sensitive assertion flaked on CI, vi.useRealTimers() was never reached, leaving fake timers active. This froze setTimeout/whenStable in later tests and spec files, producing unrelated 30s hook timeouts (e.g. in footer.component.spec.ts). Restore real timers in afterEach so a failure can no longer poison the rest of the suite.
1 parent 7dfcb9a commit 74be058

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎projects/ngx-datatable/src/lib/components/header/header.component.spec.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ describe('DataTableHeaderComponent', () => {
2626
componentRef = fixture.componentRef;
2727
});
2828

29+
afterEach(() => {
30+
vi.useRealTimers();
31+
});
32+
2933
it('should render with given column headers', async () => {
3034
componentRef.setInput(
3135
'columns',
@@ -50,7 +54,6 @@ describe('DataTableHeaderComponent', () => {
5054
// there is setTimeout in columns setter so we need to wait for it
5155
vi.advanceTimersByTime(0);
5256
expect(await harness.getHeaderRowWidth()).toBeCloseTo(500);
53-
vi.useRealTimers();
5457
});
5558

5659
it('should place header cells based on column pinning group', async () => {
@@ -245,8 +248,6 @@ describe('DataTableHeaderComponent', () => {
245248
expect(await harness.getColumnName(0)).toBe('Column 2');
246249
expect(await harness.getColumnName(1)).toBe('Column 1');
247250
expect(await harness.getColumnName(2)).toBe('Column 3');
248-
249-
vi.useRealTimers();
250251
});
251252

252253
it('should not apply translateX to center group (scroll sync via native scrollLeft)', async () => {

0 commit comments

Comments
 (0)