Skip to content

test(babel-plugin-transform-react-jsx-to-rn-stylesheet): jest to vitest#18146

Merged
yoyo837 merged 21 commits intoNervJS:mainfrom
ianzone:babel-plugin-transform-react-jsx-to-rn-stylesheet
Sep 9, 2025
Merged

test(babel-plugin-transform-react-jsx-to-rn-stylesheet): jest to vitest#18146
yoyo837 merged 21 commits intoNervJS:mainfrom
ianzone:babel-plugin-transform-react-jsx-to-rn-stylesheet

Conversation

@ianzone
Copy link
Copy Markdown
Contributor

@ianzone ianzone commented Aug 8, 2025

这个 PR 做了什么? (简要描述所做更改)
babel-plugin-transform-react-jsx-to-rn-stylesheet jest 重构为 vitest

这个 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

  • 新功能
  • 测试
    • 将测试框架从 Jest 迁移到 Vitest;新增/更新包级与仓库级 Vitest 配置以支持多包测试与覆盖收集;测试脚本改为 vitest run / vitest run --coverage;替换 it->test 并补充类型声明,保留现有断言与快照。
  • 杂务
    • 删除旧的 Jest 配置文件;新增 vitest 配置文件;CI 工作流新增并发取消与超时限制;构建脚本增加聚合输出标志。
  • 重构/样式
    • 少量注释/格式调整、本地变量重命名与局部类型断言、导出顺序微调(不影响外部接口)。
  • 影响
    • 无用户可感知的功能或对外 API 变更。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 8, 2025

Walkthrough

将子包 babel-plugin-transform-react-jsx-to-rn-stylesheet 的测试框架从 Jest 迁移到 Vitest(删除子包 jest.config.js、添加子包与根级 vitest 配置、更新 package.json 与测试文件);并做若干非功能性类型断言、注释与导出顺序微调及 CI 超时/并发配置调整。

Changes

Cohort / File(s) Summary of Changes
Jest → Vitest(子包: babel-plugin-transform-react-jsx-to-rn-stylesheet)
packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/jest.config.js, packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts, packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json, packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/index.spec.ts
删除子包 jest.config.js;新增子包 vitest.config.ts(测试 include 与 coverage 设置);package.json 测试脚本改为 vitest run / vitest run --coverage;测试用例替换为 Vitest API、增加类型签名并对 Babel transform 返回值做空值检查。
根级 Vitest 项目聚合
vitest.config.ts
新增根级 vitest.config.ts,配置 test.projects 指向 packages/*/vitest.config.ts 以启用多项目测试发现。
AST 处理类型断言
packages/babel-plugin-transform-taroapi/src/index.ts
在 Babel AST 节点替换处添加 any 类型断言及少量注释/空白调整,行为无变更。
导出顺序微调(RN 库)
packages/taro-rn/src/lib/index.ts
export * from './ENV_TYPE' 从文件顶部移动到 downloadFile 之后,导出集合保持不变。
CI 工作流与构建脚本调整
.github/workflows/nodejs.yml, package.json
为 CI 添加并发组与 timeout-minutes: 30;将根 package build 脚本加上 --aggregate-output 参数以聚合输出。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as 开发者/CI
  participant RootCfg as 根 vitest.config.ts
  participant PkgCfg as 包级 vitest.config.ts
  participant Vitest as Vitest Runner
  Dev->>RootCfg: 触发 monorepo 测试
  RootCfg->>PkgCfg: 发现 packages/*/vitest.config.ts
  Vitest->>PkgCfg: 读取包级配置 (include, coverage)
  Vitest->>Dev: 运行包内测试文件并收集覆盖率
  note right of Vitest #e6f7ff: 从单一 Jest 切换为多项目 Vitest 流程
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • tutuxxx
  • yoyo837
  • luckyadam

Poem

小兔敲键换新装,🐇
Jest 灯落舞台旁,
Vitest 轻步入心房,🔦
覆盖静静数行光,
断言稳了好安心。

✨ Finishing Touches
🧪 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 or @coderabbit 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 a review from luckyadam August 8, 2025 02:25
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (2)
packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts (1)

5-10: 建议补充 excludeglobals 以减少误报并简化测试代码

当前只指定了 include 与覆盖率范围,默认情况下 node_modulesdist 等目录仍会被 Vitest 扫描;此外如果想在测试文件中省去 import { expect } from 'vitest' 等显式导入,可以开启 globals

  test: {
    include: ['tests/**/*.spec.ts?(x)'],
+   exclude: ['dist/**', 'node_modules/**'],
+   globals: true,
    coverage: {
      provider: 'istanbul',
      include: ['src/**/*.ts'],
    }
  }
packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/index.spec.ts (1)

3-3: 若启用 Vitest globals 可移除显式导入,代码更简洁

启用 globals: true 后(见上一个评论),describe / test / expect 均为全局可用,不再需要单独导入。

-import { describe, expect, test } from 'vitest'
+// 若在 vitest.config.ts 中开启 globals,则无需此行
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae19ce5 and 3094ee8.

⛔ Files ignored due to path filters (1)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/__snapshots__/index.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (4)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/jest.config.js (0 hunks)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json (1 hunks)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/index.spec.ts (29 hunks)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/jest.config.js
🧰 Additional context used
🧠 Learnings (3)
📓 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 目录。不要假设包中存在测试目录结构。
📚 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/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/index.spec.ts
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.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/babel-plugin-transform-react-jsx-to-rn-stylesheet/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-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2025

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #18146      +/-   ##
==========================================
- Coverage   55.06%   55.05%   -0.01%     
==========================================
  Files         416      416              
  Lines       21564    21560       -4     
  Branches     5282     5298      +16     
==========================================
- Hits        11874    11870       -4     
- Misses       8032     8174     +142     
+ Partials     1658     1516     -142     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...-transform-react-jsx-to-rn-stylesheet/src/index.ts 88.78% <100.00%> (-0.20%) ⬇️
...ckages/babel-plugin-transform-taroapi/src/index.ts 97.41% <100.00%> (ø)

... and 49 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.

This was referenced Aug 9, 2025
This was referenced Sep 13, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Oct 18, 2025
1 task
This was referenced Nov 4, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 21, 2025
27 tasks
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