Skip to content

Conversation

ianzone
Copy link
Contributor

@ianzone ianzone commented Aug 18, 2025

这个 PR 做了什么? (简要描述所做更改)

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 测试

    • 迁移测试框架至 Vitest,提升执行速度与一致性
    • 将用例从 it(...) 调整为 test(...),保持断言与逻辑不变
    • 配置覆盖率收集范围,确保核心代码被统计
  • 杂项

    • 更新项目测试脚本以使用新框架
    • 移除过时的旧测试配置,减少维护负担
    • 新增集中化的测试配置文件,便于后续扩展

Copy link

coderabbitai bot commented Aug 18, 2025

Walkthrough

将 packages/css-to-react-native 包的测试框架从 Jest 迁移到 Vitest:更新 package.json 的 test 脚本并移除 Jest 配置;测试文件适配 Vitest 的导入与用例声明;新增 vitest.config.ts 配置覆盖率与测试匹配规则。

Changes

Cohort / File(s) Summary of Changes
测试运行器迁移(脚本与配置)
packages/css-to-react-native/package.json
将 scripts.test 从 "jest" 改为 "vitest run";删除整个 jest 配置块(transform、coverageDirectory、coverageReporters、coverageThreshold、testPathIgnorePatterns)。
测试用例适配 Vitest
packages/css-to-react-native/tests/index.spec.ts
引入 vitesttest;将 it(...) 替换为 test(...);移除 jest.setTimeout(1000);断言与逻辑不变。
新增 Vitest 配置
packages/css-to-react-native/vitest.config.ts
新增配置文件,使用 defineConfig;设置 test.include: ['tests/**/*.spec.ts?(x)'];启用 Istanbul 覆盖率并限定 include: ['src/**/*.ts']

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • tutuxxx
  • yoyo837

Poem

小兔敲键夕阳下,
Jest 挥手说再见啦。
Vitest 上场步伐快,
覆盖统计亮如霞。
代码仍旧稳如塔,
嘭嘭心跳:测试,出发! 🐇✨

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot requested review from tutuxxx and yoyo837 August 18, 2025 05:25
Copy link

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b3127a8 and dd12fc4.

📒 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 依赖提升策略,无需在子包中重复声明。

Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.95%. Comparing base (b3127a8) to head (dd12fc4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837 yoyo837 merged commit 851ba49 into NervJS:main Aug 19, 2025
24 checks passed
@ianzone ianzone deleted the css-rn branch August 19, 2025 06:22
This was referenced Aug 23, 2025
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