360 Secure SkillHub
360 安全技能中心

playwright

提供面向 Playwright 与 Next.js 应用的 45 条 E2E 测试最佳实践,按测试架构、选择器、等待断言、认证状态、网络模拟、Next.js 集成、性能与调试/CI 分类,并给出适用场景与规则引用,帮助编写、排查和优化测试。

PyModel
热度 0.00
最近更新 2026-10-18 21:48:35
分类:开发依赖:代码执行 / 联网浏览搜索 / 读写文件应用场景:代码生成 / 代码审查 / 调试排错 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pymodel/react-frontend-skills/playwright
Metadata
name
playwright
description
Playwright end-to-end tests and flaky-test fixes.

Playwright + Next.js Testing Best Practices

Comprehensive testing optimization guide for Playwright with Next.js applications. Contains 45 rules across 8 categories, prioritized by impact to guide reliable, fast, and maintainable E2E tests.

When to Apply

Reference these guidelines when:

  • Writing new Playwright tests for Next.js apps
  • Debugging flaky or failing tests
  • Optimizing test execution speed
  • Setting up authentication state reuse
  • Configuring CI/CD pipelines for testing
  • Testing Server Components and App Router features
  • Reviewing test code for reliability issues

Rule Categories by Priority

Priority Category Impact Prefix
1 Test Architecture CRITICAL arch-
2 Selectors & Locators CRITICAL loc-
3 Waiting & Assertions HIGH wait-
4 Authentication & State HIGH auth-
5 Mocking & Network MEDIUM-HIGH mock-
6 Next.js Integration MEDIUM next-
7 Performance & Speed MEDIUM perf-
8 Debugging & CI LOW-MEDIUM debug-

Quick Reference

1. Test Architecture (CRITICAL)

2. Selectors & Locators (CRITICAL)

3. Waiting & Assertions (HIGH)

4. Authentication & State (HIGH)

5. Mocking & Network (MEDIUM-HIGH)

6. Next.js Integration (MEDIUM)

7. Performance & Speed (MEDIUM)

8. Debugging & CI (LOW-MEDIUM)

How to Use

Run in the project root first:

npx -y @pymodel/react-frontend-skills detect                   # installed vs. targeted versions
npx -y @pymodel/react-frontend-skills scan --skill playwright  # deprecated APIs → rule IDs

Read references/<rule-id>.md for each rule above that matches the task and for each scan hit: why it matters, then incorrect vs. correct code.