qa-testing-playwright by vasilyu1983/ai-agents-public
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill qa-testing-playwright面向 Web 应用程序的高信号、成本可控的端到端测试。
核心文档:
getByRole → getByLabel/getByText → getByTestId(后备方案)。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 命令 | 用途 |
|---|---|
npm init playwright@latest | 初始化 Playwright |
npx playwright test | 运行所有测试 |
npx playwright test --grep @smoke | 运行冒烟测试 |
npx playwright test --project=chromium | 运行单个项目 |
npx playwright test --ui | 使用 UI 模式调试 |
npx playwright test --debug | 单步执行测试 |
npx playwright show-trace trace.zip | 检查追踪产物 |
npx playwright show-report | 检查 HTML 报告 |
| 场景 | 替代方案 |
|---|---|
| 单元测试 | Jest, Vitest, pytest |
| API 契约测试 | qa-api-testing-contracts |
| 负载测试 | k6, Locust, Artillery |
| 移动端原生应用测试 | Appium |
// 1. 角色定位器 (首选)
await page.getByRole('button', { name: 'Sign in' }).click();
// 2. 标签/文本定位器
await page.getByLabel('Email').fill('user@example.com');
// 3. 测试 ID 定位器 (后备方案)
await page.getByTestId('user-avatar').click();
force: true如果出现不稳定情况:
expect(...) 或有针对性的等待替换休眠。使测试独立且具有确定性
对第三方依赖使用网络模拟
在 PR 上运行冒烟 E2E 测试;按计划运行完整回归测试
默认“对所有内容进行 E2E 测试”
为了“修复”不稳定测试而削弱断言
削弱断言的自动修复
在运行昂贵的 E2E 测试之前执行此检查,以避免可预防的失败。
rg --files tests/e2e | rg <target>)。lsof -i :3001)。webServer 冲突的并行本地服务器。--grep,而非宽泛的通配符。test -f <error-context.md>)。test-results 索引。在受限环境(沙盒化终端、CI 容器、共享开发主机)中运行 Playwright 之前,决定并记录:
127.0.0.1 还是 0.0.0.0,并验证所选端口是否空闲。EPERM/EACCES 失败,立即升级处理,而非重试循环。.next/lock 并终止陈旧的构建/开发进程 PID。--workers=1 复现一个失败的测试。EADDRINUSE| 资源 | 用途 |
|---|---|
| references/playwright-mcp.md | MCP 与 AI 测试 |
| references/playwright-patterns.md | 高级模式 |
| references/playwright-ci.md | CI 配置 |
| references/playwright-authentication.md | 认证模式和会话管理 |
| references/visual-regression-testing.md | 视觉回归策略 |
| references/api-testing-playwright.md | 使用 APIRequestContext 进行 API 测试 |
| references/playwright-preflight-sandbox.md | 沙盒/端口前检查和升级决策 |
| data/sources.json | 文档链接 |
| 模板 | 用途 |
|---|---|
| assets/template-playwright-e2e-review-checklist.md | E2E 审查清单 |
| assets/template-playwright-fail-on-flaky-reporter.js | 在重试通过的不稳定测试上使 CI 失败 |
| assets/template-playwright-preflight-checklist.md | 端口/沙盒/超时前检查清单 |
| 技能 | 用途 |
|---|---|
| qa-testing-strategy | 整体测试策略 |
| software-frontend | 前端开发 |
| ops-devops-platform | CI/CD 集成 |
每周安装数
196
仓库
GitHub 星标数
46
首次出现
2026年1月23日
安全审计
安装于
gemini-cli171
opencode170
codex169
cursor167
github-copilot161
amp148
High-signal, cost-aware E2E testing for web applications.
Core docs:
getByRole → getByLabel/getByText → getByTestId (fallback).| Command | Purpose |
|---|---|
npm init playwright@latest | Initialize Playwright |
npx playwright test | Run all tests |
npx playwright test --grep @smoke | Run smoke tests |
npx playwright test --project=chromium | Run a single project |
npx playwright test --ui | Debug with UI mode |
npx playwright test --debug |
| Scenario | Use Instead |
|---|---|
| Unit testing | Jest, Vitest, pytest |
| API contracts | qa-api-testing-contracts |
| Load testing | k6, Locust, Artillery |
| Mobile native | Appium |
// 1. Role locators (preferred)
await page.getByRole('button', { name: 'Sign in' }).click();
// 2. Label/text locators
await page.getByLabel('Email').fill('user@example.com');
// 3. Test IDs (fallback)
await page.getByTestId('user-avatar').click();
force: trueIf something is flaky:
expect(...) or a targeted wait.Make tests independent and deterministic
Use network mocking for third-party deps
Run smoke E2E on PRs; full regression on schedule
"Test everything E2E" as default
Weakening assertions to "fix" flakes
Auto-healing that weakens assertions
Run this preflight before expensive E2E runs to prevent avoidable failures.
rg --files tests/e2e | rg <target>).lsof -i :3001).webServer.--grep over broad globs during triage.test -f <error-context.md>).test-results index first.Before running Playwright in constrained environments (sandboxed terminals, CI containers, shared dev hosts), decide and document:
127.0.0.1 or 0.0.0.0, and verify selected port is free.EPERM/EACCES, escalate immediately instead of retry loops..next/lock and terminate stale build/dev PIDs before rerun.--workers=1.EADDRINUSE on Playwright web server port| Resource | Purpose |
|---|---|
| references/playwright-mcp.md | MCP & AI testing |
| references/playwright-patterns.md | Advanced patterns |
| references/playwright-ci.md | CI configurations |
| references/playwright-authentication.md | Auth patterns and session management |
| references/visual-regression-testing.md | Visual regression strategies |
| references/api-testing-playwright.md | API testing with APIRequestContext |
| Template | Purpose |
|---|---|
| assets/template-playwright-e2e-review-checklist.md | E2E review checklist |
| assets/template-playwright-fail-on-flaky-reporter.js | Fail CI on rerun-pass flakes |
| assets/template-playwright-preflight-checklist.md | Preflight checklist for port/sandbox/timeouts |
| Skill | Purpose |
|---|---|
| qa-testing-strategy | Overall test strategy |
| software-frontend | Frontend development |
| ops-devops-platform | CI/CD integration |
Weekly Installs
196
Repository
GitHub Stars
46
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli171
opencode170
codex169
cursor167
github-copilot161
amp148
| Step through a test |
npx playwright show-trace trace.zip | Inspect trace artifacts |
npx playwright show-report | Inspect HTML report |
| references/playwright-preflight-sandbox.md | Sandbox/port preflight and escalation decisions |
| data/sources.json | Documentation links |