Use this skill every user want to create test file.
waitForTimeout alone when a request is triggered, MUST use page.waitForLoadState('networkidle'); followed by page.waitForTimeout(500).page.waitForTimeout(500) after every click action to prevent race conditions.// Components :
// - You must add all "Component Path" from plan markdown
import { test, expect, type Page } from '@playwright/test';
const BASE_URL = process.env.BASE_URL || 'http://localhost:5173';
const AUTH_EMAIL = process.env.AUTH_EMAIL || 'user@example.com';
const AUTH_PASSWORD = process.env.AUTH_PASSWORD || 'your-password';
// @INFO Create function mockData() to generate dynamic mock for test data. Dont add any test data into environment.
function mockData() {
// @TODO generate mock test data here
const name = "wahyu" + Date.now();
return {
name: name
}
}
async function login(page: Page) {
await page.goto(`${BASE_URL}/auth/login`);
await page.waitForLoadState('networkidle');
// @TODO(verified): Change with real selector from playwright-e2e probe
await page.locator('input[name="email"]').fill(AUTH_EMAIL);
await page.locator('input[name="password"]').fill(AUTH_PASSWORD);
await page.locator('button[type="submit"]').click();
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
}
test.describe('SCN-1: User Management - View Users List', () => {
test('SCN-1: User Management - View Users List end-to-end', async ({ page }) => {
await login(page);
await test.step('should display users list with correct elements', async () => {
// @TODO Do any step and assertion
});
// @TODO fill with next step
})
})
getByLabel.getByText.button, input, textarea, select, table, td, tr, th and etc.data-testid and getByRole.[data-testid="value"] if the component has a playwrightId="value" or data-testid="value" prop/attribute. Follow the logic in collect-selector.evaluate for assertion *.toBeVisible()