-
Notifications
You must be signed in to change notification settings - Fork 4.9k
test(taro-runtime): vitest #18056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
test(taro-runtime): vitest #18056
Conversation
Walkthrough将 taro-runtime 从 Jest 迁移到 Vitest:移除旧 Jest 配置、引入 vitest.config.ts、更新 npm test 脚本;大量测试文件改为 ESM/Vitest 风格并搬迁到 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Page as 页面/组件
participant PageCfg as Page Config [ONUNLOAD]
participant Win as TaroWindow
participant Loc as TaroLocation
participant His as TaroHistory
Note over PageCfg,Win: 卸载流程(已修正为 CONTEXT_ACTIONS.DESTROY)
PageCfg->>Win: trigger(CONTEXT_ACTIONS.DESTROY, pageId)
Win->>Loc: trigger(CONTEXT_ACTIONS.DESTROY, pageId)
Win->>His: trigger(CONTEXT_ACTIONS.DESTROY, pageId)
Loc-->>Loc: 删除 pageId 对应的 Location 缓存
His-->>His: 删除 pageId 对应的 History 缓存
Win-->>PageCfg: 卸载完成通知
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2025-08-08T02:32:58.265ZApplied to files:
🧬 Code graph analysis (1)packages/taro-runtime/src/dsl/common.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/taro-runtime/package.json (1)
25-26: 脚本切换到 Vitest ✅
脚本已对齐新框架,参数简单明了。可考虑再加一个test:watch方便本地调试:"test:watch": "vitest"packages/taro-runtime/tests/style.spec.ts (1)
11-13: 环境变量清理 OK,但建议使用 Vitest API
可用afterAll的别名vi.afterAll,避免同时引入多个同名函数后混淆。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (19)
packages/taro-runtime/jest.config.js(0 hunks)packages/taro-runtime/package.json(1 hunks)packages/taro-runtime/src/__tests__/event.spec.js(0 hunks)packages/taro-runtime/src/__tests__/mutation.spec.js(0 hunks)packages/taro-runtime/src/__tests__/react.spec.js(0 hunks)packages/taro-runtime/tests/class.spec.ts(6 hunks)packages/taro-runtime/tests/dom.spec.ts(13 hunks)packages/taro-runtime/tests/event.spec.ts(1 hunks)packages/taro-runtime/tests/eventSource.spec.ts(4 hunks)packages/taro-runtime/tests/exports.spec.ts(2 hunks)packages/taro-runtime/tests/html.spec.ts(16 hunks)packages/taro-runtime/tests/location.spec.ts(14 hunks)packages/taro-runtime/tests/mutation.spec.ts(1 hunks)packages/taro-runtime/tests/react.spec.ts(1 hunks)packages/taro-runtime/tests/style.spec.ts(1 hunks)packages/taro-runtime/tests/utils.ts(1 hunks)packages/taro-runtime/tsconfig.json(1 hunks)packages/taro-runtime/tsconfig.test.json(0 hunks)packages/taro-runtime/vitest.config.ts(1 hunks)
🧠 Learnings (14)
📓 Common learnings
Learnt from: ianzone
PR: NervJS/taro#17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 __tests__ 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: NervJS/taro#17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tsconfig.json (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/package.json (2)
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tests/style.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/class.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/exports.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/vitest.config.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/react.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/html.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/eventSource.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/dom.spec.ts (3)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: Single-Dancer
PR: #17653
File: packages/taro-components-advanced/src/components/water-flow/node.ts:83-95
Timestamp: 2025-05-06T06:55:44.077Z
Learning: 在 Taro 的 getRectSizeSync 函数中,如果找不到指定的节点,函数会一直处于 pending 状态而不是抛出错误。在这种情况下,使用 try/catch 处理不够充分,需要添加超时处理如 Promise.race 来避免无限等待。
packages/taro-runtime/tests/location.spec.ts (2)
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tests/event.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/mutation.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
💤 Files with no reviewable changes (5)
- packages/taro-runtime/tsconfig.test.json
- packages/taro-runtime/src/tests/event.spec.js
- packages/taro-runtime/jest.config.js
- packages/taro-runtime/src/tests/react.spec.js
- packages/taro-runtime/src/tests/mutation.spec.js
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: ianzone
PR: NervJS/taro#17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 __tests__ 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: NervJS/taro#17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tsconfig.json (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/package.json (2)
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tests/style.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/class.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/exports.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/vitest.config.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/react.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/html.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/eventSource.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/dom.spec.ts (3)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: Single-Dancer
PR: #17653
File: packages/taro-components-advanced/src/components/water-flow/node.ts:83-95
Timestamp: 2025-05-06T06:55:44.077Z
Learning: 在 Taro 的 getRectSizeSync 函数中,如果找不到指定的节点,函数会一直处于 pending 状态而不是抛出错误。在这种情况下,使用 try/catch 处理不够充分,需要添加超时处理如 Promise.race 来避免无限等待。
packages/taro-runtime/tests/location.spec.ts (2)
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
packages/taro-runtime/tests/event.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
packages/taro-runtime/tests/mutation.spec.ts (2)
Learnt from: ianzone
PR: #17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Learnt from: ianzone
PR: #17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 tests 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
🔇 Additional comments (38)
packages/taro-runtime/tests/utils.ts (1)
2-2: 👍 显式声明Promise<void>很好
补充返回类型让 TS 推导更准确,符合 “self-documenting code” 的理念。无其他问题。packages/taro-runtime/tests/class.spec.ts (1)
10-10: 导航器注释掉是否仍需?
若 runtime 内部有对navigator的访问,Vitest 将抛出ReferenceError。请确认后决定保留或删除该注释。packages/taro-runtime/tests/style.spec.ts (1)
1-4: 测试文件已 ESM 化 👍
引入方式统一为 ESM,提高一致性,无明显问题。packages/taro-runtime/tests/exports.spec.ts (3)
1-1: LGTM! 正确的 Vitest 导入语法使用显式导入的方式从
vitest导入测试函数,这是推荐的做法。
3-3: LGTM! 改用源码导入路径从
../src/index直接导入源码而不是构建后的分发版本,这在测试环境中是合适的做法。
10-10: LGTM! 统一使用test函数将
it更改为test以保持与 Vitest API 的一致性,这是正确的迁移做法。Also applies to: 19-19, 25-25, 30-30
packages/taro-runtime/tests/eventSource.spec.ts (4)
1-3: LGTM! 正确的 Vitest 迁移显式导入 Vitest 测试工具并改用源码导入路径,符合迁移最佳实践。
8-8: LGTM! 提高代码清晰度显式赋值
document变量提高了代码的可读性和明确性。
20-20: LGTM! 函数增强为
createDiv函数添加可选的类型化id参数,这是一个很好的改进。
29-29: LGTM! 统一测试函数命名将测试函数从
it更改为test以保持与 Vitest API 的一致性。Also applies to: 53-53
packages/taro-runtime/tests/html.spec.ts (5)
1-9: LGTM! 完整的 Vitest 迁移导入所有导入语句都已正确更新为使用源码路径和显式 Vitest 函数导入,迁移工作完整。
17-17: LGTM! 显式传递 document 参数明确传递
document对象到 parser 函数,提高了代码的清晰度。
22-22: LGTM! 统一测试函数命名所有测试用例都已从
it更改为test,与 Vitest API 保持一致。Also applies to: 42-42, 62-62, 93-93, 115-115, 137-137, 151-151, 171-171, 216-216, 253-253, 285-285, 317-317, 341-341, 347-347, 356-356, 379-379
327-327: LGTM! 测试内容微调将换行符替换为空格的内容调整是合理的测试数据修改。
Also applies to: 336-336
380-380: LGTM! 参数类型改进为
transformText函数的参数添加类型注解,提高了代码质量。packages/taro-runtime/tests/react.spec.ts (3)
1-3: LGTM! 正确的 Vitest 导入设置使用了完整的 Vitest 测试工具导入,包括
vi用于模拟函数,这是正确的设置。
5-11: LGTM! 合适的测试环境设置正确设置了 React 框架环境变量,并在测试结束后进行了清理,这是良好的测试实践。
13-25: LGTM! 完整的事件处理测试测试覆盖了事件创建、监听器注册和事件分发的完整流程,验证逻辑正确且全面。
packages/taro-runtime/vitest.config.ts (3)
1-3: LGTM! 正确的配置文件导入导入了必要的 path 工具和 Vitest 配置定义函数,设置正确。
6-14: LGTM! 完整的功能特性标志配置定义了所有必要的 DOM 相关功能特性标志,确保运行时功能的完整性,这些配置对于 taro-runtime 的正常工作至关重要。
15-22: LGTM! 完整的测试配置测试文件匹配模式、代码覆盖率配置和设置文件路径都配置正确,为 Vitest 测试提供了完整的运行环境。
packages/taro-runtime/tests/dom.spec.ts (5)
1-1: 迁移到 Vitest 框架的导入设置正确正确地导入了 Vitest 的测试函数,替换了 Jest 的隐式全局变量。
3-3: 运行时导入路径更新合理从构建后的分发版本改为直接从源代码导入,这在测试环境中更加合适。
17-226: 测试方法名称统一更新所有测试用例都正确地从
it更新为test,与 Vitest 约定保持一致。
132-132: 添加可选链操作符提高代码健壮性在
insertAdjacentHTML测试中添加了可选链操作符,这是一个很好的改进,可以防止在节点可能为 undefined 时出现运行时错误。Also applies to: 135-138, 147-148
8-10: 确认:在 dom.spec.ts 中移除 global.navigator 不会影响现有测试在 dom.spec.ts 的用例中,并未直接访问或依赖全局的
navigator;所有 DOM 操作测试均基于从src/index导出的window和document实例。
而对navigator的验证在exports.spec.ts中通过:
runtime.window.navigator和runtime.navigator均已从bom/navigator正常导出并在测试中校验,不依赖global.navigator。结论:可安全保留注释,所有当前用例均能通过。
packages/taro-runtime/tests/location.spec.ts (6)
1-3: Vitest 迁移设置正确正确地从 Jest 迁移到 Vitest,包括导入语句和运行时模块路径的更新。
6-516: 测试方法名称和模拟函数更新完整所有测试用例都正确地从
it更新为test,模拟函数从jest.fn()更新为vi.fn(),保持了 Vitest 框架的一致性。
121-121: 错误处理类型转换改进在 URL 构造函数测试中添加了错误类型转换
(error as Error),这提高了 TypeScript 类型安全性。Also applies to: 129-129, 137-137, 145-145
171-178: URL 构造函数测试参数调整将 URL 对象改为字符串作为 base 参数,这是一个合理的简化。
239-285: Router 模拟对象属性增强在
Current.router模拟对象中添加了$taroPath、onReady、onHide、onShow属性,使模拟对象更完整。
397-397: 缓存访问添加可选链在访问缓存条目时添加了可选链操作符,提高了代码的健壮性。
Also applies to: 501-502
packages/taro-runtime/tests/event.spec.ts (2)
1-11: 新事件测试套件设置完善正确使用 Vitest 框架,导入了必要的测试函数和运行时模块。测试环境清理设置合理。
12-245: 事件系统测试覆盖全面测试套件全面覆盖了事件系统的关键功能:
- 事件监听器的添加、移除和触发
- 事件冒泡和阻止传播
- 多个处理程序和一次性选项
- 默认行为阻止
- 立即停止传播
测试用例结构清晰,使用了适当的中文描述,mock 函数使用一致。
packages/taro-runtime/tests/mutation.spec.ts (4)
1-23: MutationObserver 测试套件设置规范测试套件正确使用了 Vitest 框架,生命周期钩子设置合理,包括观察器的初始化和清理。
24-91: appendChild 变异测试覆盖完整测试用例全面覆盖了 appendChild 操作的变异观察,包括首个节点、兄弟节点和深层树结构的情况,断言结构完整。
93-169: replaceChild 变异测试场景全面测试用例涵盖了 replaceChild 操作的各种场景,包括单节点和多节点的替换,正确验证了变异记录的结构。
171-284: removeChild 变异测试逻辑严谨测试用例详细验证了 removeChild 操作的变异观察,包括单个节点、多个兄弟节点和深层结构的移除,异步测试模式使用正确。
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18056 +/- ##
==========================================
+ Coverage 55.97% 56.33% +0.35%
==========================================
Files 416 447 +31
Lines 21560 23339 +1779
Branches 5267 5768 +501
==========================================
+ Hits 12069 13148 +1079
- Misses 7904 8368 +464
- Partials 1587 1823 +236
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@yoyo837 辛苦合一下哈 |
这个 PR 做了什么? (简要描述所做更改)
将 taro-runtime 的 jest 测试改为 vitest 测试
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
Bug Fixes
Refactor
Chores / Tests
Documentation