本清单基于 Epic 1 和 Epic 2 的回顾总结,确保代码质量和一致性。 参见: _bmad-output/implementation-artifacts/epic-1-retrospective.md, epic-2-retrospective.md
[ ] 所有导出函数都有完整的 JSDoc
@param - 参数说明@returns - 返回值说明@throws {E2ETestError} - 可能抛出的错误@example - 使用示例[ ] 内部函数使用 @internal 标记
/**
* @internal
* 内部辅助函数,不导出
*/
[ ] 使用 E2ETestError 而非原生 Error
// ✅ 正确
throwError({
operation: 'selectRadixOption',
target: label,
expected: value,
});
// ❌ 错误
throw new Error('Select failed');
[ ] 使用 :text-is() 而非 :has-text() 进行精确匹配
// ✅ 精确匹配
page.locator(`.option:text-is("广东省")`)
// ❌ 部分匹配 - 可能误选
page.locator(`.option:has-text("广东省")`)
[ ] 配置对象继承 BaseOptions
export interface AsyncSelectOptions extends BaseOptions {
waitForOption?: boolean;
waitForNetworkIdle?: boolean;
}
[ ] 超时值使用 DEFAULT_TIMEOUTS 常量
import { DEFAULT_TIMEOUTS } from './constants.js';
await page.waitForTimeout(DEFAULT_TIMEOUTS.static);
[ ] 网络空闲等待使用用户自定义的超时值
// ✅ 正确 - 使用用户自定义的 timeout
await page.waitForLoadState('networkidle', {
timeout: options.timeout ?? DEFAULT_TIMEOUTS.async
});
// ❌ 错误 - 使用固定的 networkIdle 超时
await page.waitForLoadState('networkidle', {
timeout: DEFAULT_TIMEOUTS.networkIdle
});
[ ] 避免使用 page.evaluate() 处理 DOM 操作
// ❌ 不推荐 - TypeScript 类型问题
const text = await page.evaluate(el => el.textContent, element);
// ✅ 推荐 - 使用 Playwright API
const text = await element.textContent();
// ✅ 推荐 - 使用 locator 获取多个文本
const texts = await page.locator(selector).allTextContents();
[ ] 单元测试无法发现真实 DOM 结构问题
[ ] 使用真实组件验证工具
运行以下命令确保代码符合规范:
# 类型检查
pnpm typecheck
# ESLint 检查
pnpm lint
# 单元测试
pnpm test:unit
# 覆盖率检查
pnpm test:coverage
在提交代码或创建 PR 之前,确保:
any 类型)E2ETestError:text-is()DEFAULT_TIMEOUTS| 模式 | 正确 | 错误 |
|---|---|---|
| 文本匹配 | :text-is("value") |
:has-text("value") |
| 错误处理 | E2ETestError |
Error |
| DOM 操作 | element.textContent() |
page.evaluate() |
| 超时配置 | DEFAULT_TIMEOUTS.static |
2000 (硬编码) |
| 网络等待 | options.timeout |
DEFAULT_TIMEOUTS.networkIdle |
_bmad-output/planning-artifacts/architecture.md_bmad-output/implementation-artifacts/epic-1-retrospective.md_bmad-output/implementation-artifacts/epic-2-retrospective.md