Skip to content

Commit 13bd8c0

Browse files
committed
III-6948: add a helper function to suppress the hydration errors
1 parent 66f5e25 commit 13bd8c0

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

src/test/e2e/events/event-preview-actions.spec.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { expect, test as base } from '@playwright/test';
22
import { addDays, subDays } from 'date-fns';
33

4+
import { suppressHydrationErrors } from '../helpers/suppress-hydration-errors';
5+
46
type TestFixtures = {
57
eventPreviewUrl: string;
68
eventId: string;
@@ -9,11 +11,7 @@ type TestFixtures = {
911
const test = base.extend<TestFixtures>({
1012
eventId: async ({ page, baseURL }, applyFixture) => {
1113
// todo: remove when the styled components hydration errors are fixed.
12-
page.on('console', (msg) => {
13-
if (msg.type() === 'error' && msg.text().includes('Hydration')) {
14-
return;
15-
}
16-
});
14+
suppressHydrationErrors(page);
1715
await page.goto(`${baseURL}/create`);
1816

1917
await page.getByRole('button', { name: 'Evenement' }).click();
@@ -64,11 +62,7 @@ test.describe('Event Preview Sidebar Actions', () => {
6462
},
6563
]);
6664
// todo: remove when the styled components hydration errors are fixed.
67-
page.on('console', (msg) => {
68-
if (msg.type() === 'error' && msg.text().includes('Hydration')) {
69-
return;
70-
}
71-
});
65+
suppressHydrationErrors(page);
7266

7367
await page.goto(eventPreviewUrl);
7468
await page.getByRole('button', { name: 'Bewerken' }).waitFor();

src/test/e2e/events/movie-preview-actions.spec.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { expect, test as base } from '@playwright/test';
22
import { addDays, subDays } from 'date-fns';
33

4+
import { suppressHydrationErrors } from '../helpers/suppress-hydration-errors';
5+
46
type TestFixtures = {
57
moviePreviewUrl: string;
68
movieEventId: string;
@@ -9,11 +11,7 @@ type TestFixtures = {
911
const test = base.extend<TestFixtures>({
1012
movieEventId: async ({ page, baseURL }, applyFixture) => {
1113
// todo: remove when the styled components hydration errors are fixed.
12-
page.on('console', (msg) => {
13-
if (msg.type() === 'error' && msg.text().includes('Hydration')) {
14-
return;
15-
}
16-
});
14+
suppressHydrationErrors(page);
1715
await page.goto(`${baseURL}/create`);
1816

1917
await page.getByRole('button', { name: 'Evenement' }).click();
@@ -68,11 +66,7 @@ test.describe('Movie Preview Sidebar Actions', () => {
6866
},
6967
]);
7068
// todo: remove when the styled components hydration errors are fixed.
71-
page.on('console', (msg) => {
72-
if (msg.type() === 'error' && msg.text().includes('Hydration')) {
73-
return;
74-
}
75-
});
69+
suppressHydrationErrors(page);
7670

7771
await page.goto(moviePreviewUrl);
7872
await page.getByRole('button', { name: 'Bewerken', exact: true }).waitFor();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Page } from '@playwright/test';
2+
3+
export const suppressHydrationErrors = (page: Page) => {
4+
page.on('console', (msg) => {
5+
if (msg.type() === 'error' && msg.text().includes('Hydration')) {
6+
return;
7+
}
8+
});
9+
};

0 commit comments

Comments
 (0)