Skip to content

Conversation

@SoonIter
Copy link
Member

@SoonIter SoonIter commented Jan 9, 2026

Summary

Related issues

AI Summary


Changes Made

This PR adds end-to-end testing for rspress-plugin-mermaid using Playwright, following the same pattern established by #18 for katex.

New files:

  • packages/rspress-plugin-mermaid/index.spec.ts - Playwright e2e test that verifies mermaid diagrams render correctly
  • packages/rspress-plugin-mermaid/vitest.config.ts - Excludes .spec.ts files from vitest (e2e tests should run via playwright)

Why

Each plugin has a docs directory and rspress.config.ts for debugging during development. Adding e2e tests ensures that the mermaid plugin renders diagrams correctly in a real browser environment, catching rendering issues that unit tests cannot detect.

Implementation Details

  • Uses shared utility functions from e2e/utils.ts (runDevCommand, killProcess)
  • Test starts a dev server, navigates to the docs page, and verifies the mermaid SVG is visible
  • Uses svg[id^="r"] selector to locate the mermaid-rendered SVG element
  • Follows the same test structure as rspress-plugin-katex for consistency

How to Test

pnpm e2e

This PR was written using Vibe Kanban


**创建的文件:**

1. `packages/rspress-plugin-mermaid/index.spec.ts` - Playwright e2e 测试文件
   - 使用 `runDevCommand` 启动开发服务器
   - 使用 `killProcess` 清理进程
   - 测试检测 mermaid 渲染的 SVG 元素是否可见

2. `packages/rspress-plugin-mermaid/vitest.config.ts` - 排除 spec 文件
   - 避免 vitest 运行 playwright 测试文件

**说明:**
- 公共函数 `runDevCommand`、`runBuildCommand`、`runPreviewCommand` 已存在于 `e2e/utils.ts`
- `playwright.config.ts` 已存在于项目根目录,配置了 `testMatch: 'packages/**/*.spec.ts'`
- 运行 `pnpm e2e` 即可执行所有插件的 e2e 测试
@SoonIter SoonIter changed the title 给 mermaid 增加 index.spec.ts 用于 e2e (vibe-kanban) test(rspress-plugin-mermaid): add e2e test with playwright Jan 9, 2026
…s` 文件了。

问题是 vitest 在运行时尝试加载 `index.spec.ts`,但这个文件是给 Playwright 用的。包级别的 `vitest.config.ts` 会排除这些文件。
@SoonIter SoonIter merged commit 13f2885 into main Jan 9, 2026
2 checks passed
@SoonIter SoonIter deleted the syt-vibe-kanban/5518-mermaid-index-sp branch January 9, 2026 06:34
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.

2 participants