Skip to content

Playwright 测试计划 ​

一、测试概述 ​

本文档定义了 VitePress 技术博客的 E2E 测试计划,使用 Playwright 框架。

二、测试范围 ​

类别测试项优先级
页面加载各页面 HTTP 200P0
首页Hero, Features, ActionsP0
导航顶部导航、侧边栏P0
文章内容渲染、链接跳转P0
SEOMeta 标签P1
响应式移动端布局P2

三、测试用例 ​

3.1 页面加载测试 ​

用例 ID描述预期结果
TC-001访问首页HTTP 200, 标题包含"技术博客"
TC-002访问文章列表HTTP 200, 侧边栏显示
TC-003访问文章详情HTTP 200, 内容显示
TC-004访问关于页HTTP 200, 内容显示

3.2 首页测试 ​

用例 ID描述预期结果
TC-101Hero 标题显示"技术博客"
TC-102Hero 副标题显示"探索技术的无限可能"
TC-103Features 数量3 个特性卡片
TC-104Actions 按钮"开始阅读"、"关于我"按钮存在

3.3 导航测试 ​

用例 ID描述预期结果
TC-201顶部导航栏存在"首页"、"文章"、"关于"链接
TC-202导航跳转点击"文章"跳转至 /posts/
TC-203侧边栏显示文章列表

3.4 链接测试 ​

用例 ID描述预期结果
TC-301外部链接GitHub 链接可访问
TC-302内部链接无 404 错误

3.5 SEO 测试 ​

用例 ID描述预期结果
TC-401Meta description存在且非空
TC-402Title 标签正确设置

四、测试文件结构 ​

tests/
├── blog.spec.ts        # 主测试文件
└── playwright.config.ts # 配置文件

五、运行命令 ​

bash
# 安装 Playwright 浏览器
npx playwright install chromium

# 运行所有测试
npx playwright test

# 运行指定测试
npx playwright test tests/blog.spec.ts

# UI 模式
npx playwright test --ui

六、环境要求 ​

  • Node.js 18+
  • Playwright 1.59+
  • 开发服务器运行在本地 5174 端口

Released under the MIT License.