From 7738c5adeeafa9845ab6ba53db3a0bbbf7ff3711 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 09:22:17 +0000 Subject: [PATCH] Refactor e2e tests to use test.beforeEach Extract repeated `await page.goto('/')` from individual test cases into a `test.beforeEach` block to reduce code duplication and improve maintainability in `tests/e2e.spec.ts`. Co-authored-by: xRahul <1639945+xRahul@users.noreply.github.com> --- tests/e2e.spec.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/e2e.spec.ts b/tests/e2e.spec.ts index e237e7f5..03ce7b88 100644 --- a/tests/e2e.spec.ts +++ b/tests/e2e.spec.ts @@ -1,22 +1,20 @@ import { test, expect } from '@playwright/test'; -test('has title', async ({ page }) => { +test.beforeEach(async ({ page }) => { await page.goto('/'); +}); +test('has title', async ({ page }) => { // Expect a title "to contain" a substring. await expect(page).toHaveTitle(/Rahul Jain/); }); test('has main heading', async ({ page }) => { - await page.goto('/'); - // Expect the main heading to be visible await expect(page.locator('h1.title')).toBeVisible(); }); test('has social links', async ({ page }) => { - await page.goto('/'); - // Check for social links await Promise.all([ expect(page.getByLabel('Stack Overflow')).toBeVisible(),