使用Playwright和Express MCP服务器的Mini.ro测试自动化

项目结构
.
├── tests/ # Playwright E2E tests
│ └── bmw.spec.ts # BMW website tests
├── mcp-server/ # Model Context Protocol server
│ ├── src/ # Source code
│ │ ├── server.ts # Main server file
│ │ ├── middleware/ # Middleware components
│ │ └── __tests__/ # Test files
│ └── package.json # Server dependencies
├── playwright.config.ts # Playwright configuration
└── package.json # Main project dependencies设置和安装
- 安装依赖项:
npm install
cd mcp-server && npm install- 安装Playwright浏览器:
npx playwright install- 设置环境变量:
- 复制 .env.example 到 .env 在mcp服务器目录中 - 根据您的环境更新值
运行测试
E2E测试(剧作家)
npm run test # Run all tests
npm run test:headed # Run tests in headed mode
npm run test:ui # Run tests with UIMCP服务器测试
cd mcp-server
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage持续集成
本项目使用GitHub Actions进行持续集成:
- E2E测试:对每个推拉请求运行Playwright测试
- MCP服务器测试:使用多个Node.js版本测试服务器
- 组合工作流:确保所有测试套件在合并前通过
CI功能
- 并行测试执行
- 多个Node.js版本测试
- 用于缓存测试的Redis服务容器
- 测试覆盖率报告
- 测试报告的工件上传
- 自动浏览器安装
- 依赖缓存
开发指南
- 为新功能编写测试
- 保持测试覆盖率在80%以上
- 在推送之前,在本地运行完整的测试套件
- 推送后检查CI结果
安全
- API端点的JWT身份验证
- 限制利率以防止滥用
- 所有请求的输入验证
- 安全的环境变量处理
监控
- 健康检查端点
- 绩效指标收集
- 错误记录和跟踪
- Redis缓存监控
替换 {owner} 和 {repo} 在徽章URL中显示您的实际GitHub存储库信息。
