14 Playwright Mistakes Slowing Your Team Down : A Daily Series
1 You are logging in through the UI in every single test. Open the app. Type the email. Type the password. Click login. Wait for the redirect. Now multiply that by 200 tests. That is 200 login scre...

Source: DEV Community
1 You are logging in through the UI in every single test. Open the app. Type the email. Type the password. Click login. Wait for the redirect. Now multiply that by 200 tests. That is 200 login screens that have nothing to do with what you are actually testing. We audited a suite last month. 38% of total test runtime was spent on the login page. Not on testing features. On typing credentials into a form. The fix is simple. Log in once via API, save the session, and every test loads that file and starts already authenticated. // BEFORE - Every test logs in through the UI test('check dashboard stats', async ({ page }) => { await page.goto('/login'); await page.getByLabel('Email').fill('[email protected]'); await page.getByLabel('Password').fill('password123'); await page.getByRole('button', { name: 'Sign in' }).click(); await page.waitForURL('/dashboard'); await expect(page.getByTestId('stats-panel')).toBeVisible(); }); // AFTER - Login once, reuse session across all tests // auth.setu