-
Notifications
You must be signed in to change notification settings - Fork 4.9k
test(taro-css-to-react-native): jest to vitest #18215
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将 packages/css-to-react-native 包的测试框架从 Jest 迁移到 Vitest:更新 package.json 的 test 脚本并移除 Jest 配置;测试文件适配 Vitest 的导入与用例声明;新增 vitest.config.ts 配置覆盖率与测试匹配规则。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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/Issue comments)Type 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: 0
🧹 Nitpick comments (3)
packages/css-to-react-native/tests/index.spec.ts (1)
3642-3655
: 性能断言可能在 CI 上偶发抖动,建议略微放宽阈值在资源紧张或虚拟化环境下,
100k
字符参与解析的测试可能超过 1s。为降低 flaky 风险,建议将阈值提高到 1500ms(或使用更稳健的基准方法)。可直接修改断言阈值如下:
- expect(duration).toBeLessThan(1000) + expect(duration).toBeLessThan(1500)packages/css-to-react-native/vitest.config.ts (2)
7-10
: 覆盖率 include 仅匹配 .ts,若 src 为 JS/TSX 会导致覆盖率统计缺失当前仅包含
'src/**/*.ts'
。如果该包的源码存在.js/.jsx/.tsx
,覆盖率会被遗漏。建议统一覆盖常见扩展,并排除.d.ts
。可按下述方式调整(兼容性更好):
- coverage: { - provider: 'istanbul', - include: ['src/**/*.ts'], - } + coverage: { + provider: 'istanbul', + include: ['src/**/*.{ts,tsx,js,jsx}'], + exclude: ['src/**/*.d.ts'] + }如需确认实际源码后缀,请运行我在 tests 文件评论中提供的脚本查看统计结果。
5-11
: 如需延续之前的超时策略,可显式设置 Vitest 超时若历史上通过
jest.setTimeout(...)
收紧过默认用例超时,可在此处用test.timeout
进行统一设置。当前默认超时为 Vitest 默认值(通常 5s),若无需收紧可忽略本建议。示例(可选):
export default defineConfig({ test: { + // 可选:如需延续更严格的默认超时(例如 1s),按需开启 + // timeout: 1000, include: ['tests/**/*.spec.ts?(x)'], coverage: { provider: 'istanbul', - include: ['src/**/*.ts'], + include: ['src/**/*.{ts,tsx,js,jsx}'], + exclude: ['src/**/*.d.ts'] } } })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
packages/css-to-react-native/package.json
(1 hunks)packages/css-to-react-native/tests/index.spec.ts
(176 hunks)packages/css-to-react-native/vitest.config.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 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.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
📚 Learning: 2025-08-08T02:32:58.265Z
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.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Applied to files:
packages/css-to-react-native/package.json
packages/css-to-react-native/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 WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (4)
packages/css-to-react-native/tests/index.spec.ts (2)
1-1
: 迁移到 Vitest 的测试 DSL ✅顶端引入
describe/expect/test
来自vitest
,全文件用例切换到test(...)
,未见 Jest API 残留。逻辑保持不变,可读性良好。
1-3656
: ✅ 确认无 Jest 遗留引用或配置
- 在
packages/css-to-react-native
中未发现任何jest.
或@jest
相关引用测试已彻底切换至 Vitest,无需保留任何 Jest 配置或代码片段。
packages/css-to-react-native/package.json (2)
19-19
: 测试脚本切换为 Vitest ✅
"test": "vitest run"
更契合 CI 一次性执行场景。与 monorepo 的依赖提升策略(在根管理 vitest 及覆盖率插件)一致。
19-19
: 根 package.json 已包含 Vitest 及覆盖率插件依赖已在仓库根目录的 package.json 中确认存在
- “vitest”: "^3.2.4"
- “@vitest/coverage-istanbul”: "^3.2.4"
符合 monorepo 依赖提升策略,无需在子包中重复声明。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18215 +/- ##
========================================
Coverage 54.95% 54.95%
========================================
Files 419 419
Lines 21750 21750
Branches 5388 5349 -39
========================================
Hits 11953 11953
+ Misses 8286 8153 -133
- Partials 1511 1644 +133
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
测试
杂项