Skip to content

Commit 9dfdfe2

Browse files
test(checkbox): migrate to toHaveScreenshot (#28085)
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 0f5ce8e commit 9dfdfe2

File tree

148 files changed

+22
-22
lines changed

Some content is hidden

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

148 files changed

+22
-22
lines changed

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

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

1414
const checkbox = page.locator('ion-checkbox');
15-
expect(await checkbox.screenshot()).toMatchSnapshot(screenshot(`checkbox-color-checked`));
15+
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-color-checked`));
1616
});
1717

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

2626
const checkbox = page.locator('ion-checkbox');
27-
expect(await checkbox.screenshot()).toMatchSnapshot(screenshot(`checkbox-color-unchecked`));
27+
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-color-unchecked`));
2828
});
2929
});
3030
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ configs().forEach(({ title, screenshot, config }) => {
1515
config
1616
);
1717
const list = page.locator('ion-list');
18-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`checkbox-list`));
18+
await expect(list).toHaveScreenshot(screenshot(`checkbox-list`));
1919
});
2020
test('should render correctly in inset list', async ({ page }) => {
2121
await page.setContent(
@@ -29,7 +29,7 @@ configs().forEach(({ title, screenshot, config }) => {
2929
config
3030
);
3131
const list = page.locator('ion-list');
32-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`checkbox-inset-list`));
32+
await expect(list).toHaveScreenshot(screenshot(`checkbox-inset-list`));
3333
});
3434
});
3535
});
@@ -46,7 +46,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
4646
config
4747
);
4848
const item = page.locator('ion-item');
49-
expect(await item.screenshot()).toMatchSnapshot(screenshot(`checkbox-item-color`));
49+
await expect(item).toHaveScreenshot(screenshot(`checkbox-item-color`));
5050
});
5151
});
5252
});
@@ -67,7 +67,7 @@ configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, co
6767
config
6868
);
6969
const list = page.locator('ion-list');
70-
expect(await list.screenshot()).toMatchSnapshot(screenshot(`checkbox-long-label-in-item`));
70+
await expect(list).toHaveScreenshot(screenshot(`checkbox-long-label-in-item`));
7171
});
7272
});
7373
});

0 commit comments

Comments
 (0)