Skip to content

Commit 7810d00

Browse files
crisbetojelbourn
authored andcommitted
test: rework flaky tests that depend on getComputedStyle (#16487)
Currently most of the grid list tests as well as one of tab nav bar test are flaky, because we use `getComputedStyle` for assertions and the return values can be formatted differently depending on the browser. These changes move them to either pick up values directly from the DOM or to measure the element with `getBoundingClientRect`.
1 parent b823dbd commit 7810d00

File tree

3 files changed

+123
-88
lines changed

3 files changed

+123
-88
lines changed

src/material/datepicker/datepicker.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ describe('MatDatepicker', () => {
178178

179179
const popup = document.querySelector('.cdk-overlay-pane')!;
180180
expect(popup).not.toBeNull();
181-
expect(parseInt(getComputedStyle(popup).height as string)).not.toBe(0);
181+
expect(popup.getBoundingClientRect().height).toBeGreaterThan(0);
182182

183183
testComponent.datepicker.close();
184184
fixture.detectChanges();
185185
flush();
186186

187-
expect(parseInt(getComputedStyle(popup).height as string)).toBe(0);
187+
expect(popup.getBoundingClientRect().height).toBe(0);
188188
}));
189189

190190
it('should close the popup when pressing ESCAPE', fakeAsync(() => {

0 commit comments

Comments
 (0)