Skip to content

fix(rstest): resolve manual mock targets with resolver#13439

Merged
fi3ework merged 5 commits intomainfrom
rstest-mock-resolve
Mar 26, 2026
Merged

fix(rstest): resolve manual mock targets with resolver#13439
fi3ework merged 5 commits intomainfrom
rstest-mock-resolve

Conversation

@9aoy
Copy link
Copy Markdown
Contributor

@9aoy 9aoy commented Mar 23, 2026

Summary

resolve manual mock targets with resolver.

Fix the case where a mocked relative request resolves through a directory entry file such as index.js / index.ts.

Before this change, rs.mock("./common") would resolve the mock target as ./__mocks__/common, even when ./common actually resolved to ./common/index.ts. That caused rstest to miss mocks placed under ./common/__mocks__/index.

After this change, when a relative mock request points to a real directory, rstest resolves the manual mock to the nested directory form:

  • source: ./common
  • actual module: ./common/index.ts
  • manual mock: ./common/__mocks__/index

Related links

fix web-infra-dev/rstest#613

Checklist

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

@9aoy 9aoy requested a review from LingyuCoder as a code owner March 23, 2026 08:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ca43b01c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

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

Generated by Rsdoctor GitHub Action

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

📦 Binary Size-limit

Comparing 2a4732a to chore(ci): remove stale miri config (#13465) by neverland

❌ Size increased by 21.00KB from 48.97MB to 48.99MB (⬆️0.04%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 23, 2026

Merging this PR will not alter performance

✅ 23 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing rstest-mock-resolve (2a4732a) with main (1c683d6)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@9aoy 9aoy requested a review from fi3ework March 24, 2026 06:13
Copy link
Copy Markdown
Member

@fi3ework fi3ework left a comment

Choose a reason for hiding this comment

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

  • should respect mainFiles instead of hard code index
  • better to use resolver to resolve instead of manually is_dir

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
examples ✅ success
rsbuild-rsc-plugin ✅ success
devserver ✅ success
plugin ❌ failure
rslib ❌ failure
rsdoctor ✅ success
lynx-stack ❌ failure
rstest ❌ failure
rsbuild ✅ success
rspress ✅ success

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 25, 2026

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2a4732a
Status: ✅  Deploy successful!
Preview URL: https://ca5a9b27.rspack-v2.pages.dev
Branch Preview URL: https://rstest-mock-resolve.rspack-v2.pages.dev

View logs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

📝 Ecosystem CI detail: Open

suite result
devserver ✅ success
plugin ✅ success
examples ✅ success
rsbuild-rsc-plugin ✅ success
lynx-stack ❌ failure
rstest ✅ success
modernjs ❌ failure
rsdoctor ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ✅ success

@9aoy 9aoy requested a review from fi3ework March 26, 2026 02:53
@9aoy 9aoy changed the title fix(rstest): resolve directory entry manual mocks from nested __mocks__ fix(rstest): resolve manual mock targets with resolver Mar 26, 2026
@fi3ework
Copy link
Copy Markdown
Member

👍🏻

@fi3ework fi3ework merged commit 12f9230 into main Mar 26, 2026
49 checks passed
@fi3ework fi3ework deleted the rstest-mock-resolve branch March 26, 2026 10:55
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.

[Bug]: rs.mock()doesn't load barrel files

2 participants