test(babel-plugin-transform-react-jsx-to-rn-stylesheet): jest to vitest#18146
Conversation
Walkthrough将子包 babel-plugin-transform-react-jsx-to-rn-stylesheet 的测试框架从 Jest 迁移到 Vitest(删除子包 jest.config.js、添加子包与根级 vitest 配置、更新 package.json 与测试文件);并做若干非功能性类型断言、注释与导出顺序微调及 CI 超时/并发配置调整。 Changes
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 流程
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts (1)
5-10: 建议补充exclude与globals以减少误报并简化测试代码当前只指定了
include与覆盖率范围,默认情况下node_modules、dist等目录仍会被 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: 若启用 Vitestglobals可移除显式导入,代码更简洁启用
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
⛔ Files ignored due to path filters (1)
packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/tests/__snapshots__/index.spec.ts.snapis 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.tspackages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.jsonpackages/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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
这个 PR 做了什么? (简要描述所做更改)
babel-plugin-transform-react-jsx-to-rn-stylesheet jest 重构为 vitest
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit