Skip to content

Commit abc8118

Browse files
test(radio): migrate to toHaveScreenshot (#28083)
Issue number: N/A --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Several tests for this component are still using Playwright's old `toMatchSnapshot` assertion. It's now recommended to use the newer `toHaveScreenshot` assertion. This new assertion reduces the size of each screenshot and brings anti-flake improvements such as disabling animations by default. We previously migrated most of our codebase to use `toHaveScreenshot`, but it looks like we missed the tests that were written during the development of Ionic 7 in a separate branch off `main`. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Migrate component tests to use `toHaveScreenshot`. Note: There should be no layout changes to any of the screenshots. The only difference between the old and new screenshots should be image and file size. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: ionitron <[email protected]>
1 parent f379c72 commit abc8118

File tree

118 files changed

+18
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+18
-18
lines changed

core/src/components/radio/test/color/radio.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
1414
);
1515

1616
const radio = page.locator('ion-radio');
17-
expect(await radio.screenshot()).toMatchSnapshot(screenshot(`radio-color-checked`));
17+
await expect(radio).toHaveScreenshot(screenshot(`radio-color-checked`));
1818
});
1919

2020
test('should not apply color when unchecked', async ({ page }) => {
@@ -28,7 +28,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
2828
);
2929

3030
const radio = page.locator('ion-radio');
31-
expect(await radio.screenshot()).toMatchSnapshot(screenshot(`radio-color-unchecked`));
31+
await expect(radio).toHaveScreenshot(screenshot(`radio-color-unchecked`));
3232
});
3333
});
3434
});
-1.59 KB
-1.79 KB
-2.9 KB
-3.34 KB
-1.42 KB
-1.48 KB
-2.18 KB
-2.81 KB

core/src/components/radio/test/item/radio.e2e.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ configs().forEach(({ title, screenshot, config }) => {
1717
config
1818
);
1919
const list = page.locator('ion-list');
20-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`toggle-list`));
20+
await expect(list).toHaveScreenshot(screenshot(`toggle-list`));
2121
});
2222
test('should render correctly in inset list', async ({ page }) => {
2323
await page.setContent(
@@ -33,7 +33,7 @@ configs().forEach(({ title, screenshot, config }) => {
3333
config
3434
);
3535
const list = page.locator('ion-list');
36-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`radio-inset-list`));
36+
await expect(list).toHaveScreenshot(screenshot(`radio-inset-list`));
3737
});
3838
});
3939
});
@@ -56,7 +56,7 @@ configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, co
5656
config
5757
);
5858
const list = page.locator('ion-list');
59-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`radio-long-label-in-item`));
59+
await expect(list).toHaveScreenshot(screenshot(`radio-long-label-in-item`));
6060
});
6161
});
6262
});

0 commit comments

Comments
 (0)