fix(rstest): always hoist @rstest/core init fragment#12363
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where using rs functions (like rs.fn()) in mock factory functions would cause a "Cannot read properties of undefined" error. The fix ensures that the @rstest/core import is always hoisted to the top of the module, not just when rs.hoisted() is used.
Key changes:
- Removed the condition that only hoisted
@rstest/coreforMockMethod::Hoisted - Updated the comment to reflect that hoisting now applies to all hoisted code
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🎉 Size decreased by 128bytes from 47.72MB to 47.72MB (⬇️0.00%) |
CodSpeed Performance ReportMerging #12363 will not alter performanceComparing Summary
|
Summary
currently, following code will raise an error
Cannot read properties of undefined (reading 'rs'). since usingrsfunction is a common pattern, so we hoist it anyway.Related links
Checklist