-
Notifications
You must be signed in to change notification settings - Fork 4.9k
test(@tarojs/shared): jest to vitest #18148
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
Conversation
Walkthrough本次变更将 Changes
Sequence Diagram(s)sequenceDiagram
participant 开发者 as Developer
participant Vitest
participant 源码 as Source Files
participant 覆盖率 as Coverage
开发者->>Vitest: 运行测试 (vitest run)
Vitest->>源码: 加载并执行 tests/**/*.spec.ts(x)
Vitest->>覆盖率: 收集 src/**/*.ts 的覆盖率
Vitest-->>开发者: 输出测试结果和覆盖率报告
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 3
🔭 Outside diff range comments (1)
packages/shared/tests/hooks.spec.ts (1)
59-61:toBeCalledTimes同样需替换为toHaveBeenCalledTimes
保持断言 API 与 Vitest 规范一致,可避免运行期错误。- expect(fnA).toBeCalledTimes(0) + expect(fnA).toHaveBeenCalledTimes(0)
🧹 Nitpick comments (1)
packages/shared/tests/shared.spec.ts (1)
5-7: 移除多余的async关键字
此测试用例并未使用await,保留async会造成异步语义误导,建议去掉。- test('#indent', async () => { + test('#indent', () => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/shared/jest.config.js(0 hunks)packages/shared/package.json(1 hunks)packages/shared/tests/hooks.spec.ts(8 hunks)packages/shared/tests/shared.spec.ts(1 hunks)packages/shared/tsconfig.test.json(0 hunks)packages/shared/vitest.config.ts(1 hunks)
💤 Files with no reviewable changes (2)
- packages/shared/tsconfig.test.json
- packages/shared/jest.config.js
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
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 文件。
📚 Learning: 2025-08-08T02:32:58.207Z
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Applied to files:
packages/shared/tests/shared.spec.tspackages/shared/package.jsonpackages/shared/vitest.config.tspackages/shared/tests/hooks.spec.ts
📚 Learning: 2025-06-23T00:09:31.233Z
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 目录。不要假设包中存在测试目录结构。
Applied to files:
packages/shared/tests/shared.spec.tspackages/shared/package.jsonpackages/shared/vitest.config.tspackages/shared/tests/hooks.spec.ts
📚 Learning: 2025-05-25T18:02:31.387Z
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 文件。
Applied to files:
packages/shared/package.jsonpackages/shared/tests/hooks.spec.ts
📚 Learning: 2025-07-22T09:16:21.180Z
Learnt from: ianzone
PR: NervJS/taro#18056
File: packages/taro-runtime/tsconfig.json:10-10
Timestamp: 2025-07-22T09:16:21.180Z
Learning: 在使用 rollup-plugin-dts 的项目中,rollup.config.ts 等构建配置文件会被自动排除,不需要在 tsconfig.json 中手动排除。
Applied to files:
packages/shared/vitest.config.ts
⏰ 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). (5)
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18148 +/- ##
========================================
Coverage 54.95% 54.95%
========================================
Files 419 419
Lines 21750 21750
Branches 5337 5368 +31
========================================
Hits 11953 11953
- Misses 8123 8241 +118
+ Partials 1674 1556 -118
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
这个 PR 做了什么? (简要描述所做更改)
@tarojs/shared 测试重构
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit