Skip to content

fix(rstest): rstest.importActual not work when imported from @rstest/core #12908

Merged
fi3ework merged 6 commits intomainfrom
rstest-importActual
Feb 2, 2026
Merged

fix(rstest): rstest.importActual not work when imported from @rstest/core #12908
fi3ework merged 6 commits intomainfrom
rstest-importActual

Conversation

@9aoy
Copy link
Copy Markdown
Contributor

@9aoy 9aoy commented Feb 2, 2026

Summary

  • fix rstest.importActual not works when imported from @rstest/core

Previously, rstest.importActual and rstest.requireActual only worked when rs or rstest were free (global) variables. When imported from @rstest/core via ESM (e.g., import { rstest } from '@rstest/core'), the for_name parameter in call_member_chain would be the ESM specifier tag instead of the variable name, causing the check to fail.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

9aoy added 2 commits February 2, 2026 12:00
…hain

Previously, `rstest.importActual` and `rstest.requireActual` only worked
when `rs` or `rstest` were free (global) variables. When imported from
`@rstest/core` via ESM (e.g., `import { rstest } from '@rstest/core'`),
the `for_name` parameter in `call_member_chain` would be the ESM specifier
tag instead of the variable name, causing the check to fail.

This fix extracts the variable name directly from the `call_expr.callee`
AST node, enabling proper handling of ESM imported variables.
@9aoy 9aoy requested a review from LingyuCoder as a code owner February 2, 2026 06:34
Copilot AI review requested due to automatic review settings February 2, 2026 06:34
@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Feb 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes rs/rstest.importActual/requireActual handling when rs/rstest is imported from @rstest/core (ESM), and introduces a globals option intended to control whether global rs/rstest variables are processed.

Changes:

  • Add globals option to rstest plugin options (Rust + Node binding types) with default true.
  • Update parser hook logic to detect rs/rstest from the call expression callee (supporting ESM import usage).
  • Extend test case to cover rs.importActual(...) when rs is imported from @rstest/core.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/rspack-test/configCases/rstest/mock/rspack.config.js Passes globals: true into the rstest plugin configuration for the test case.
tests/rspack-test/configCases/rstest/mock/importActual.js Adds ESM import of rs from @rstest/core and asserts rs.importActual works.
crates/rspack_plugin_rstest/src/plugin.rs Plumbs new globals option into parser plugin construction.
crates/rspack_plugin_rstest/src/parser_plugin.rs Fixes call_member_chain detection for ESM-imported rs/rstest and adds globals option to the parser plugin.
crates/rspack_binding_api/src/rstest.rs Exposes globals?: boolean to bindings and defaults it to true.
crates/node_binding/napi-binding.d.ts Adds globals?: boolean to TypeScript typings for plugin options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (5ea17c9836) does not have baseline artifacts. Using commit c3b14c0d37 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
rome 984.2 KB 0
ui-components 2.2 MB 0
react-5k 2.7 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 086713c to refactor: incremental.buildChunkGraph works only for skip building chunk graph (#12845) by Fy

❌ Size increased by 256bytes from 48.27MB to 48.27MB (⬆️0.00%)

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 2, 2026

@9aoy I've opened a new pull request, #12909, to work on those changes. Once the pull request is ready, I'll request review from you.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 2, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing rstest-importActual (086713c) with main (c3b14c0)1

Summary

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark2

Footnotes

  1. No successful run was found on main (5ea17c9) during the generation of this report, so c3b14c0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 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 requested a review from fi3ework February 2, 2026 09:57
@9aoy 9aoy changed the title fix(rstest): rstest.importActual not works when imported from @rstest/core fix(rstest): rstest.importActual not work when imported from @rstest/core Feb 2, 2026
@9aoy 9aoy requested a review from fi3ework February 2, 2026 11:54
@fi3ework fi3ework merged commit 5d43d3b into main Feb 2, 2026
74 of 76 checks passed
@fi3ework fi3ework deleted the rstest-importActual branch February 2, 2026 13:41
9aoy added a commit that referenced this pull request Feb 3, 2026
…st/core` (#12908)

* fix(rstest): handle ESM imported rs/rstest variables in call_member_chain

Previously, `rstest.importActual` and `rstest.requireActual` only worked
when `rs` or `rstest` were free (global) variables. When imported from
`@rstest/core` via ESM (e.g., `import { rstest } from '@rstest/core'`),
the `for_name` parameter in `call_member_chain` would be the ESM specifier
tag instead of the variable name, causing the check to fail.

This fix extracts the variable name directly from the `call_expr.callee`
AST node, enabling proper handling of ESM imported variables.

* feat: only handle global `rs` and `rstest` variables when globals true

* fix: clippy warnings

* fix: remove globals option (other PR)

* chore: useless Clippy lint ignore

* test: split cases
9aoy added a commit that referenced this pull request Feb 3, 2026
…st/core` (#12918)

fix(rstest): `rstest.importActual` not work when imported from `@rstest/core`  (#12908)
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) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants