Skip to content

fix(rstest): apply globals option consistently to all rstest methods#12909

Closed
Copilot wants to merge 2 commits intorstest-importActualfrom
copilot/sub-pr-12908
Closed

fix(rstest): apply globals option consistently to all rstest methods#12909
Copilot wants to merge 2 commits intorstest-importActualfrom
copilot/sub-pr-12908

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 2, 2026

The globals option only gated importActual/requireActual in call_member_chain. Other methods (mock, doMock, importMock, etc.) in handle_rstest_method_call ignored this option, causing inconsistent behavior where globals: false would still transform global rs/rstest usage.

Changes

  • Added global variable check at entry to handle_rstest_method_call using parser.is_variable_defined()
  • Skip processing when identifier is global and globals: false
  • Applies consistently to: mock, mockRequire, doMock, doMockRequire, importMock, requireMock, unmock, doUnmock, resetModules, hoisted

Behavior

// Before: globals: false only affected importActual/requireActual
rs.mock('./foo')      // ❌ Still transformed (inconsistent)
rs.importActual('./foo')  // ✅ Skipped (as expected)

// After: globals: false affects all methods
rs.mock('./foo')      // ✅ Skipped (consistent)
rs.importActual('./foo')  // ✅ Skipped (consistent)

// ESM imports always processed regardless of globals setting
import { rs } from '@rstest/core'
rs.mock('./foo')      // ✅ Transformed (both before and after)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] WIP address feedback on rstest.importActual functionality fix(rstest): apply globals option consistently to all rstest methods Feb 2, 2026
Copilot AI requested a review from 9aoy February 2, 2026 07:10
@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Feb 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (2f1eebb0bc) does not have baseline artifacts. Using commit 953025ee89 for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
rome 984.2 KB 0
ui-components 2.2 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

📦 Binary Size-limit

Comparing 2409720 to feat: support import.defer() for statical path (#12900) by Gengkun

🎉 Size decreased by 896bytes from 48.31MB to 48.31MB (⬇️0.00%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 2, 2026

Merging this PR will not alter performance

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing copilot/sub-pr-12908 (2409720) with rstest-importActual (d636d4f)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@9aoy 9aoy closed this Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants