Mistake 4: Writing Tests Without Assertions
This is a BIG one.
Some beginners write:
await page.getByLabel('Username').fill('admin');
await page.getByLabel('Password').fill('admin123');
await page.getByRole('button', { name: 'Login' }).click();
The test completes.
But what did you actually verify?
Nothing.
The test could technically pass even if login failed.
Bad automation
Perform actions → End test
Good automation
Perform actions → Verify expected behavior
await page.getByLabel('Username').fill('admin');
await page.getByLabel('Password').fill('admin123');
await page.getByRole('button', { name: 'Login' }).click();
await expect(page.getByText('Dashboard')).toBeVisible();
QA Tip
Every important business flow should answer:
“What exactly am I validating?”
Mistake 5: Creating One Giant Test
Imagine one test does:
Login
↓
Create customer
↓
Create order
↓
Update order
↓
Generate invoice
↓
Logout
If step 4 fails…
You may have no idea which functionality actually caused the problem.
Giant test :
Hard to:
- Debug
- Maintain
- Re-run
- Understand
Better approach :
Break your scenarios into focused tests.
test('User can login', async ({ page }) => {
// login steps
});
test('User can create customer', async ({ page }) => {
// customer steps
});
test('User can create order', async ({ page }) => {
// order steps
});
Think like a QA engineer :
A test should ideally answer one clear question.
Mistake 6: Repeating the Same Login Code Everywhere
Imagine you have 50 tests.
And every test contains:
await page.goto('/login');
await page.getByLabel('Username').fill('admin');
await page.getByLabel('Password').fill('admin123');
await page.getByRole('button', { name: 'Login' }).click();
That’s a maintenance nightmare.
What if the login flow changes?
You may need to update dozens of tests.
Better approach :
Use reusable functions, fixtures, or authentication state.
For example:
async function login(page: Page) {
await page.getByLabel('Username').fill('admin');
await page.getByLabel('Password').fill('admin123');
await page.getByRole('button', { name: 'Login' }).click();
}
Then:
await login(page);
Framework Mindset :
If you’re copying the same code repeatedly, stop and ask:
“Should this become reusable?”
That’s how a collection of scripts starts becoming a real automation framework.