Skip to content

chore(e2e): add unified console error detection fixtures - #206

Merged
Gaubee merged 1 commit into
mainfrom
chore/e2e-console-error-detection
Jan 10, 2026
Merged

Gaubee merged 1 commit into
mainfrom
chore/e2e-console-error-detection

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Summary

添加统一的 E2E 测试 fixtures,用于检测控制台和页面错误。

Changes

新增 e2e/fixtures.ts:

Fixtures

  • consoleErrors: 收集测试期间的控制台错误,测试结束时断言无未处理错误
  • pageErrors: 收集未捕获的 JavaScript 错误

允许的错误模式

以下错误不会导致测试失败:

  • React 开发模式警告 (Warning:)
  • Vite HMR 消息
  • 网络请求失败(mock 环境预期)
  • ResizeObserver loop 警告
  • Source map 加载失败

Usage

// 替换原有导入
// import { test, expect } from '@playwright/test'
import { test, expect } from './fixtures'

test('my test', async ({ page, consoleErrors, pageErrors }) => {
  await page.goto('/')
  // ... 测试逻辑
  // 测试结束时自动检查 consoleErrors 和 pageErrors
})

Notes

  • 使用 expect.soft 以便看到所有错误而不是第一个就停止
  • 现有测试无需修改,只需更改导入即可启用

- Add e2e/fixtures.ts with extended test fixtures
- consoleErrors: Collects and asserts no unexpected console errors
- pageErrors: Collects and asserts no uncaught JavaScript errors
- ALLOWED_ERROR_PATTERNS: Whitelist for expected errors (React warnings, Vite HMR, network failures, etc.)

Usage: Import { test, expect } from './fixtures' instead of '@playwright/test'
@Gaubee
Gaubee merged commit 999d49a into main Jan 10, 2026
5 checks passed
@Gaubee
Gaubee deleted the chore/e2e-console-error-detection branch January 10, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant