Browse Source

📝 docs(architecture): 更新mini-demo迁移指南文档

- 版本历史添加2.1版本记录,说明修正Taro测试位置
- 更新测试结构示例,将测试文件路径从tests/unit/mini/调整为mini/tests/
- 修改测试代码示例,使用@tarojs/test-utils-react替代@testing-library/react
- 调整测试方法,使用testUtils.mount和异步查询方式
yourname 4 tháng trước cách đây
mục cha
commit
77f0241e0a
1 tập tin đã thay đổi với 13 bổ sung6 xóa
  1. 13 6
      docs/architecture/mini-demo-migration-guide.md

+ 13 - 6
docs/architecture/mini-demo-migration-guide.md

@@ -3,6 +3,7 @@
 ## 版本信息
 | 版本 | 日期 | 描述 | 作者 |
 |------|------|------|------|
+| 2.1 | 2025-10-15 | 修正Taro测试位置,统一使用mini/tests/目录 | Winston |
 | 2.0 | 2025-10-15 | 整合精确样式迁移内容,优化文档结构 | Winston |
 | 1.0 | 2025-10-15 | 初始mini-demo迁移指导规范 | Winston |
 
@@ -482,18 +483,24 @@ export default function HomePage() {
 
 **新测试结构:**
 ```typescript
-// tests/unit/mini/pages/home/index.test.tsx
-import { render } from '@testing-library/react'
+// mini/tests/pages/home/index.test.tsx
+import TestUtils from '@tarojs/test-utils-react'
 import HomePage from '@/pages/home/index'
 
+const testUtils = new TestUtils()
+
 describe('HomePage', () => {
-  it('renders travel type selector', () => {
-    const { getByText } = render(<HomePage />)
-    expect(getByText('大巴拼车')).toBeInTheDocument()
+  it('renders travel type selector', async () => {
+    await testUtils.mount(HomePage)
+    const travelTypeSelector = await testUtils.queries.waitForQuerySelector('.travel-type-selector')
+    expect(travelTypeSelector).toBeInTheDocument()
   })
 
-  it('handles location selection', () => {
+  it('handles location selection', async () => {
     // 测试地点选择功能
+    await testUtils.mount(HomePage)
+    const locationPicker = await testUtils.queries.waitForQuerySelector('.location-picker')
+    expect(locationPicker).toBeInTheDocument()
   })
 })
 ```