by vitalics
Playwright 测试经常出现不稳定、执行缓慢和维护困难的问题。此技能根据 40 多条经过验证的最佳实践(组织为 8 个类别)审查 TypeScript 测试代码,提供具体的改进建议和清晰的示例。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 playwright-best-practices 技能" 开始使用
=== playwright-best-practices 技能 === 作者: vitalics 描述: Playwright 测试经常出现不稳定、执行缓慢和维护困难的问题。此技能根据 40 多条经过验证的最佳实践(组织为 8 个类别)审查 TypeScript 测试代码,提供具体的改进建议和清晰的示例。 使用方法: 1. 调用技能: "使用 playwright-best-practices 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 playwright-best-practices 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
coding
low
A structured repository for creating and maintaining Playwright TypeScript Best Practices optimized for agents and LLMs.
rules/ - Individual rule files (one per rule)
_sections.md - Section metadata (titles, impacts, descriptions)_template.md - Template for creating new rulesarea-description.md - Individual rule filessrc/ - Build scripts and utilitiesmetadata.json - Document metadata (version, organization, abstract)AGENTS.md - Compiled output (generated)test-cases.json - Test cases for LLM evaluation (generated)pnpx add-skill https://github.com/vitalics/playwright-labs/tree/main/packages/playwright-best-practices # pnpm
npx add-skill https://github.com/vitalics/playwright-labs/tree/main/packages/playwright-best-practices # npm
Install dependencies:
pnpm install
Build AGENTS.md from rules:
pnpm build
Validate rule files:
pnpm validate
Extract test cases:
pnpm extract-tests
rules/_template.md to rules/area-description.mdstable- for Test Stability & Reliability (Section 1)speed- for Test Execution Speed (Section 2)locator- for Locator Best Practices (Section 3)assertion- for Assertions & Waiting (Section 4)parallel- for Parallel Execution (Section 5)fixture- for Fixtures & Test Organization (Section 6)debug- for Debugging & Maintenance (Section 7)advanced- for Advanced Patterns (Section 8)pnpm build to regenerate AGENTS.md and test-cases.jsonEach rule file should follow this structure:
---
title: Rule Title Here
impact: MEDIUM
impactDescription: Optional description
tags: tag1, tag2, tag3
---
## Rule Title Here
Brief explanation of the rule and why it matters.
**Incorrect (description of what's wrong):**
```typescript
// Bad code example
```
Correct (description of what's right):
// Good code example
Optional explanatory text after examples.
Reference: Link
_ are special (excluded from build)area-description.md (e.g., stable-auto-waiting.md)CRITICAL - Highest priority, major stability/performance gainsHIGH - Significant test reliability improvementsMEDIUM-HIGH - Moderate-high gainsMEDIUM - Moderate improvementsLOW-MEDIUM - Low-medium gainsLOW - Incremental improvementspnpm build - Compile rules into AGENTS.mdpnpm validate - Validate all rule filespnpm extract-tests - Extract test cases for LLM evaluationpnpm dev - Build and validateWhen adding or modifying rules:
_template.md structurepnpm build to regenerate AGENTS.md and test-cases.jsonThe foundation of reliable test automation. Flaky tests undermine confidence and waste developer time.
Fast feedback loops are essential for developer productivity and CI/CD pipelines.
Robust locators are the backbone of maintainable tests that survive UI changes.
Proper assertions and waiting strategies prevent flakiness and ensure tests validate the right things.
Efficient parallel test execution dramatically reduces total test suite runtime.
Well-organized tests with proper fixtures improve maintainability and reusability.
Good debugging practices and maintainable test code reduce time spent fixing tests.
Advanced patterns for specific cases that require careful implementation.
Inspired by the agent-skills repository structure from @shuding at Vercel.
View Count
0
Download Count
0
Favorite Count
0
Quality Score
68