To troubleshoot a failing test in @playwright/test, follow these steps:
Understand the cause: Tests can be "passed", "flaky", or "failed". A flaky test fails on the first run but passes when retried. A failed test fails on all retries.
Detect retries at runtime: Use testInfo.retry
to access retry information in tests, hooks, or fixtures. This helps you clear server-side state before a retry if needed.
Specify retries for specific tests: Use test.describe.configure()
to control retries for a group of tests or a single file.
Debug locally in VSCode: Install the VS Code extension and run tests in debug mode by right-clicking on the line next to the test you want to run. Live debug by clicking or editing locators while running in debug mode.
import { test, expect } from '@playwright/test';
test('basic test', async ({ page }) => {
await page.goto('https://ray.run/');
const title = await page.title();
expect(title).toBe('Ray');
});
By following these steps and using Playwright's debugging tools, you'll be able to identify and resolve issues efficiently.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].