From e5e8c772ac7b9dfd50d79ee860bd9cadb403e566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Fri, 6 Mar 2026 12:57:43 +0800 Subject: [PATCH] docs: add comprehensive README documentation --- test-framework/README.md | 140 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 test-framework/README.md diff --git a/test-framework/README.md b/test-framework/README.md new file mode 100644 index 0000000..ab19223 --- /dev/null +++ b/test-framework/README.md @@ -0,0 +1,140 @@ +# 测试框架 + +统一的测试框架,整合了E2E测试和开发环境测试。 + +## 目录结构 + +``` +test-framework/ +├── shared/ # 共享层 +│ ├── config/ # 配置管理 +│ ├── pages/ # 页面对象 +│ ├── utils/ # 工具类 +│ ├── fixtures/ # 测试fixtures +│ └── types/ # 类型定义 +├── dev-audit/ # 开发环境测试 +│ ├── performance/ # 性能测试 +│ ├── seo/ # SEO测试 +│ ├── accessibility/ # 可访问性测试 +│ └── forms/ # 表单测试 +├── e2e/ # E2E测试示例 +├── reports/ # 测试报告 +├── docs/ # 文档 +├── playwright.config.ts # Playwright配置 +├── package.json # 依赖和脚本 +├── tsconfig.json # TypeScript配置 +└── run-all-tests.sh # 一键测试脚本 +``` + +## 快速开始 + +### 安装依赖 + +```bash +npm install +npm run test:install +``` + +### 运行测试 + +```bash +# 运行所有测试 +npm run test + +# 运行特定类型的测试 +npm run test:dev-audit:performance +npm run test:dev-audit:seo +npm run test:dev-audit:accessibility +npm run test:dev-audit:forms + +# 一键运行所有测试 +./run-all-tests.sh +``` + +### 查看报告 + +```bash +npm run test:report +``` + +## 测试类型 + +### 性能测试 +- 页面加载性能 +- Core Web Vitals +- 资源加载时间 + +### SEO测试 +- Meta标签验证 +- 标题结构检查 +- 链接验证 + +### 可访问性测试 +- WCAG 2.1 AA合规性 +- 颜色对比度检查 +- Alt文本验证 + +### 表单测试 +- 必填字段验证 +- 格式验证 +- 提交功能测试 + +## 配置 + +测试配置位于 `shared/config/` 目录: + +- `base.config.ts` - 基础配置 +- `environments.ts` - 环境配置 +- `test-pages.ts` - 测试页面配置 +- `test-data.ts` - 测试数据配置 + +## 页面对象 + +所有页面对象位于 `shared/pages/` 目录,继承自 `BasePage`。 + +可用的页面对象: +- `BasePage` - 基础页面对象 +- `HomePage` - 首页 +- `AboutPage` - 关于页面 +- `ContactPage` - 联系页面 +- `ProductsPage` - 产品页面 +- `ServicesPage` - 服务页面 +- `CasesPage` - 案例页面 +- `NewsPage` - 新闻页面 + +## 工具类 + +- `PerformanceMonitor` - 性能监控 +- `LighthouseRunner` - Lighthouse审计 +- `CoreWebVitals` - Core Web Vitals +- `AccessibilityTester` - 可访问性测试 +- `SEOValidator` - SEO验证 +- `TestReporter` - 测试报告生成器 + +## Fixtures + +测试fixtures位于 `shared/fixtures/` 目录: + +- `base.fixture.ts` - 基础fixtures(页面对象和配置) +- `performance.fixture.ts` - 性能测试fixtures +- `accessibility.fixture.ts` - 可访问性测试fixtures + +## 环境变量 + +- `TEST_ENV` - 测试环境(development/staging/production) +- `BASE_URL` - 基础URL(可选,覆盖配置) + +## 报告 + +测试报告生成在 `reports/` 目录: + +- `html/` - HTML格式的可视化报告 +- `json/` - JSON格式的结构化数据 + +## 贡献 + +请遵循项目的代码规范和测试最佳实践。 + +## 许可证 + +MIT