BrauzerLab
← Back to missions 27 / 50

Fix the Flaky Test

Hard ~240 sec

page.waitForTimeout(500) — you’ll often see this line in older test suites. The problem: 500 ms is sometimes too short, sometimes too long. As a result the test passes sometimes and fails other times — a flaky test.

The correct fix: expect(locator).toBeVisible(). This assertion waits until the element is visible — based on real state, not an arbitrary number of milliseconds.

page is available. Remove the waitForTimeout line from the starter code and replace it with a visibility assertion using expect.

TASK

Fix the flaky test.

Provided for you
import { test, expect } from '@playwright/test';

test('Fix the Flaky Test', async ({ page }) => {
  await page.goto('https://lab.local/mission/fix-flaky-test');
  // ↓ Your code goes below ↓
});
Editor
https://lab.local/mission/fix-flaky-test
Loading...
Results will appear here — press Run or Check.