Skip to content

Commit cddefd1

Browse files
test(input): migrate input to toHaveScreenshot (#28084)
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 437ef16 commit cddefd1

File tree

333 files changed

+72
-80
lines changed

Some content is hidden

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

333 files changed

+72
-80
lines changed

core/src/components/input/test/bottom-content/input.e2e.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
1111
config
1212
);
1313
const input = page.locator('ion-input');
14-
expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-full-bottom-no-fill`));
14+
await expect(input).toHaveScreenshot(screenshot(`input-full-bottom-no-fill`));
1515
});
1616
test('entire input component should render correctly with solid fill', async ({ page }) => {
1717
await page.setContent(
@@ -21,7 +21,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
2121
config
2222
);
2323
const input = page.locator('ion-input');
24-
expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-full-bottom-solid`));
24+
await expect(input).toHaveScreenshot(screenshot(`input-full-bottom-solid`));
2525
});
2626
test('entire input component should render correctly with outline fill', async ({ page }) => {
2727
await page.setContent(
@@ -31,7 +31,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
3131
config
3232
);
3333
const input = page.locator('ion-input');
34-
expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-full-bottom-outline`));
34+
await expect(input).toHaveScreenshot(screenshot(`input-full-bottom-outline`));
3535
});
3636
});
3737
});
@@ -94,7 +94,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
9494
);
9595

9696
const errorText = page.locator('ion-input .error-text');
97-
expect(await errorText.screenshot()).toMatchSnapshot(screenshot(`input-error-custom-color`));
97+
await expect(errorText).toHaveScreenshot(screenshot(`input-error-custom-color`));
9898
});
9999
});
100100
test.describe('input: hint text rendering', () => {
@@ -103,7 +103,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
103103
await page.setContent(`<ion-input helper-text="my helper" label="my input"></ion-input>`, config);
104104

105105
const bottomEl = page.locator('ion-input .input-bottom');
106-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`input-bottom-content-helper`));
106+
await expect(bottomEl).toHaveScreenshot(screenshot(`input-bottom-content-helper`));
107107
});
108108
test('should not have visual regressions when rendering error text', async ({ page }) => {
109109
await page.setContent(
@@ -112,7 +112,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
112112
);
113113

114114
const bottomEl = page.locator('ion-input .input-bottom');
115-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`input-bottom-content-error`));
115+
await expect(bottomEl).toHaveScreenshot(screenshot(`input-bottom-content-error`));
116116
});
117117
});
118118
});
@@ -179,7 +179,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
179179
await page.setContent(`<ion-input counter="true" maxlength="20" label="my input"></ion-input>`, config);
180180

181181
const bottomEl = page.locator('ion-input .input-bottom');
182-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`input-bottom-content-counter`));
182+
await expect(bottomEl).toHaveScreenshot(screenshot(`input-bottom-content-counter`));
183183
});
184184
});
185185
});

0 commit comments

Comments
 (0)