Skip to content

Commit 1437510

Browse files
committed
fix(e2e): remove redundant timeouts and update isDevelopment logic
- Eliminate unnecessary `waitForTimeout` calls for improved test performance in `teach.spec.ts`. - Refactor `playwright.config.ts` to enhance `isDevelopment` logic, ensuring proper handling of CI and local development environments.
1 parent b5b6583 commit 1437510

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

playwright.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { defineConfig, devices } from '@playwright/test';
22

33
const MAX_DIFF_PIXEL_RATIO = 0.025 as const;
44

5+
const isDevelopment = !process.env.CI;
6+
57
export default defineConfig({
68
globalSetup: require.resolve('./test/global-setup.ts'),
7-
forbidOnly: !!process.env.CI,
8-
retries: process.env.CI ? 2 : 0,
9-
reporter: process.env.CI ? 'playwright-teamcity-reporter' : 'list',
9+
forbidOnly: !isDevelopment,
10+
retries: isDevelopment ? 0 : 2,
11+
reporter: isDevelopment ? 'list' : 'playwright-teamcity-reporter',
1012
snapshotDir: 'test/snapshots',
1113
expect: {
14+
timeout: isDevelopment ? 10000 : 5000,
1215
toMatchSnapshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO },
1316
toHaveScreenshot: { maxDiffPixelRatio: MAX_DIFF_PIXEL_RATIO }
1417
},

test/production/teach.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ test.describe('Teach page', () => {
99
const whyTeachKotlinButton = page.getByRole('link', { name: 'Why Teach Kotlin' }).first();
1010
await expect(whyTeachKotlinButton).toBeVisible();
1111
await whyTeachKotlinButton.click();
12-
await page.waitForTimeout(3000);
1312
await expect(page.url()).toContain('/education/why-teach-kotlin/');
1413
});
1514

1615
test('List of courses button in navbar opens the related page', async ({ page }) => {
1716
const listOfCoursesButton = page.getByRole('link', { name: 'List of Courses' });
1817
await expect(listOfCoursesButton).toBeVisible();
1918
await listOfCoursesButton.click();
20-
await page.waitForTimeout(3000);
2119
await expect(page.url()).toContain('/education/courses/');
2220
});
2321

@@ -55,16 +53,14 @@ test.describe('Teach page', () => {
5553
const whyTeachKotlinButton = page.getByRole('link', { name: 'Why Teach Kotlin' }).nth(1);
5654
await expect(whyTeachKotlinButton).toBeVisible();
5755
await whyTeachKotlinButton.click();
58-
await page.waitForTimeout(3000);
5956
await expect(page.url()).toContain('/education/why-teach-kotlin');
6057
});
6158

6259
test('All universities button opens the related page', async ({ page }) => {
6360
const allUniversitiesButton = page.getByRole('link', { name: 'All universities' });
6461
await expect(allUniversitiesButton).toBeVisible();
6562
await allUniversitiesButton.click();
66-
await page.waitForTimeout(3000);
67-
await expect(page.url()).toContain('/education/courses');
63+
expect(page.url()).toContain('/education/courses');
6864
});
6965

7066
test('Slack-channel button in context opens the related page', async ({ page, context }) => {
@@ -74,6 +70,6 @@ test.describe('Teach page', () => {
7470
await joinEducatorsButton.click();
7571
const newPage = await newPagePromise;
7672
await newPage.waitForLoadState();
77-
await expect(newPage.url()).toContain('https://surveys.jetbrains.com/s3/kotlin-slack-signup-educators');
73+
expect(newPage.url()).toContain('https://surveys.jetbrains.com/s3/kotlin-slack-signup-educators');
7874
});
7975
});

0 commit comments

Comments
 (0)