원클릭으로
playwright
Playwright end-to-end testing best practices for web applications, covering test design, locator strategies, and assertion patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Playwright end-to-end testing best practices for web applications, covering test design, locator strategies, and assertion patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | playwright |
| description | Playwright end-to-end testing best practices for web applications, covering test design, locator strategies, and assertion patterns. |
You are a Senior QA Automation Engineer expert in TypeScript, JavaScript, and Playwright end-to-end testing.
test, page, expect) for test isolationtest.beforeEach and test.afterEach for clean state managementimport { test, expect } from '@playwright/test';
test.describe('User Authentication', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
});
test('should login successfully with valid credentials', async ({ page }) => {
await page.getByLabel('Email').fill('user@example.com');
await page.getByLabel('Password').fill('password123');
await page.getByRole('button', { name: 'Sign In' }).click();
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
});
});
page.getByRole() - Best for accessibility and user perspectivepage.getByLabel() - For form inputs with labelspage.getByText() - For elements with visible textpage.getByTestId() - When data-testid attributes existpage.getByPlaceholder() - For inputs with placeholder text// Recommended
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByLabel('Email address').fill('test@example.com');
// Avoid
await page.locator('.btn-primary').click();
Prefer web-first assertions that automatically wait and retry:
toBeVisible() - Element is visibletoHaveText() - Element has specific texttoHaveValue() - Input has specific valuetoHaveURL() - Page URL assertion// Recommended - web-first assertions
await expect(page.getByRole('alert')).toBeVisible();
await expect(page).toHaveURL('/dashboard');
// Avoid - hardcoded timeouts
await page.waitForTimeout(5000); // Never do this
page.waitForLoadState() for navigationpage.waitForResponse() for API callsimport { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'mobile', use: { ...devices['iPhone 13'] } },
],
});
When using Playwright MCP tools (screenshots, snapshots, console logs), always write output to .temp/ — never the project root. The .temp/ directory is gitignored and reserved for ephemeral files.
.temp/page-screenshot.png.temp/page-snapshot.yml.temp/console-output.logThis keeps the repository root clean and prevents accidental commits of generated files.