Skip to content

Commit 7dc9d2d

Browse files
test(textarea): migrate to toHaveScreenshot (#28087)
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 c8d214a commit 7dc9d2d

File tree

309 files changed

+71
-77
lines changed

Some content is hidden

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

309 files changed

+71
-77
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
5353
);
5454

5555
const errorText = page.locator('ion-textarea .error-text');
56-
expect(await errorText.screenshot()).toMatchSnapshot(screenshot(`textarea-error-custom-color`));
56+
await expect(errorText).toHaveScreenshot(screenshot(`textarea-error-custom-color`));
5757
});
5858
});
5959
test.describe('textarea: hint text rendering', () => {
@@ -62,7 +62,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
6262
await page.setContent(`<ion-textarea helper-text="my helper" label="my textarea"></ion-textarea>`, config);
6363

6464
const bottomEl = page.locator('ion-textarea .textarea-bottom');
65-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`textarea-bottom-content-helper`));
65+
await expect(bottomEl).toHaveScreenshot(screenshot(`textarea-bottom-content-helper`));
6666
});
6767
test('should not have visual regressions when rendering error text', async ({ page }) => {
6868
await page.setContent(
@@ -71,7 +71,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
7171
);
7272

7373
const bottomEl = page.locator('ion-textarea .textarea-bottom');
74-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`textarea-bottom-content-error`));
74+
await expect(bottomEl).toHaveScreenshot(screenshot(`textarea-bottom-content-error`));
7575
});
7676
});
7777
});
@@ -137,7 +137,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
137137
);
138138

139139
const bottomEl = page.locator('ion-textarea .textarea-bottom');
140-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`textarea-bottom-content-counter`));
140+
await expect(bottomEl).toHaveScreenshot(screenshot(`textarea-bottom-content-counter`));
141141
});
142142

143143
test('should not have visual regressions when rendering counter with helper text', async ({ page }) => {
@@ -147,9 +147,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
147147
);
148148

149149
const bottomEl = page.locator('ion-textarea .textarea-bottom');
150-
expect(await bottomEl.screenshot()).toMatchSnapshot(
151-
screenshot(`textarea-bottom-content-counter-helper-text`)
152-
);
150+
await expect(bottomEl).toHaveScreenshot(screenshot(`textarea-bottom-content-counter-helper-text`));
153151
});
154152

155153
test('should not have visual regressions when rendering counter with error text', async ({ page }) => {
@@ -159,7 +157,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, co
159157
);
160158

161159
const bottomEl = page.locator('ion-textarea .textarea-bottom');
162-
expect(await bottomEl.screenshot()).toMatchSnapshot(screenshot(`textarea-bottom-content-counter-error-text`));
160+
await expect(bottomEl).toHaveScreenshot(screenshot(`textarea-bottom-content-counter-error-text`));
163161
});
164162
});
165163
});

0 commit comments

Comments
 (0)